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());
        }
    }
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());
        }
    }
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 ( ) ) ; } }
Initialise the resource for writing.

If we are at 0, then write initial block, otherwise, remove closing block and add a row separator

This is so we can append a file with special characters at the beginning and end
Initialise the resource for writing .