When writing to a file, the first thing you need to do is to open up the file. We do that with this code:

Code:
<?php 
 $File = "YourFile.txt"; 
 $Handle = fopen($File, 'w');
 ?>