public function writeLine($string)
    {
        $string = rtrim($string, "\n\r") . PHP_EOL;
        if ($this->getFileObject()->fwrite($string) === false) {
            // return written bytes or null on error
            throw new FileWriterException('write line to file failed.');
        }
        return $this;
    }