public function close()
    {
        if ($this->stream === null) {
            return;
        }
        if (false === @fclose($this->stream)) {
            // FAILED.
            $msg = "Cannot fclose " . $this->__toString() . " $php_errormsg";
            throw new IOException($msg);
        }
        $this->stream = null;
    }