public function __construct($filename) { $this->file = fopen($filename, 'w+'); if (!$this->file) { throw new \RuntimeException('Could not open file for writing'); } }