public function write($string, $length = null)
    {
        if (null === $length) {
            $length = strlen($string);
        }

        if (false === ($actual = @fwrite($this->getHandle(), $string, $length))) {
            throw FileException::createUsingLastError();
        }

        if ($length !== $actual) {
            throw FileException::createUsingFormat(
                'Only %d of %d bytes were written to "%s".',
                $actual,
                $length,
                $this->file
            );
        }
    }