Replaced file_put_contents with fwrite.