$myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); fwrite($myfile, $sqlContents); fclose($myfile);