TypeError thrown

fwrite(): Argument #1 ($stream) must be of type resource, bool given