Oh, you're right. Sorry I posted the wrong copy of the code. Here is the correct code:
<?php
$filename = "xmlGenerator.php";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$handle2 = fopen("galleryXML.xml", 'w');
fwrite($handle2, $contents);
?>
Either way. How can I execute the PHP then have it written to the file. I tried just including all the code and setting it = to the variable $contents but I had trouble with that, negating all the quotes and such and I had a few error thrown I couldn't seem to fix.