Used file_put_contents instead of fwrite