private function initialiseForWriting()
    {
        // move to the end of the file to always append
        fseek($this->stream, 0, SEEK_END);

        if (ftell($this->stream) === 0) {
            fwrite($this->stream, $this->formatter->getInitialBlock());
        } elseif (strlen($this->formatter->getClosingBlock()) > 0) {
            $endBlock = $this->formatter->getClosingBlock();
            fseek($this->stream, strlen($endBlock) * -1, SEEK_CUR);
            fwrite($this->stream, $this->formatter->getRowSeparator());
        } elseif (strlen($this->formatter->getRowSeparator()) > 0) {
            fwrite($this->stream, $this->formatter->getRowSeparator());
        }
    }