private function getChunkedString($string)
    {
        $firstLine = '';
        if ($this->tell() !== 0) {
            $next = $this->lineLength - ($this->position % ($this->lineLength + $this->lineEndingLength));
            if (strlen($string) > $next) {
                $firstLine = substr($string, 0, $next) . $this->lineEnding;
                $string = substr($string, $next);
            }
        }
        // chunk_split always ends with the passed line ending
        $chunked = $firstLine . chunk_split($string, $this->lineLength, $this->lineEnding);
        return substr($chunked, 0, strlen($chunked) - $this->lineEndingLength);
    }