public function createWriter(bool $append = true): CsvWriterInterface
    {
        $stream = $this->openStream($append ? 'a+' : 'w+');

        $writer = new CsvStreamWriter($stream);
        $writer->setCsvControl($this->delimiter, $this->enclosure, $this->escape);

        if ($this->associativeRows) {
            $writer = new AssociativeWriterDecorator($writer);
            if ($this->headers) {
                $writer->setHeaders($this->headers);
            }
        }

        return $writer;
    }