changed fopen+fread+fwrite with file_put_contents()