HELP! Using PHP, Flash and XML to rewrite file

<?php
$file = fopen("user.xml", "w+") or die("Can't open XML file");
$xmlString = $HTTP_RAW_POST_DATA; 
if(!fwrite($file, $xmlString)){
    print "Error writing to XML-file";
}
print $xmlString."
";
fclose($file);
?>

I have this code currently from a Kirupa tutorial but this only adds to the xml file. I want it so that it will completely rewrite the xml. Please help!