public function close()
    {
        if (null !== $this->contents) {
            $result = file_put_contents($this->filename, json_encode($this->contents));
            if (false === $result) {
                throw new IOException('Unable to write to file!');
            }
            $this->contents = null;
        }
    }