Here's a list of the escape characters:
http://www.php.net/manual/phpfi2.php#escapes
As to your other question about clearing a file. If you open the file like:
$fp = fopen( "filename.txt", 'w' );
it will empty the file (or create it if it doesn't exist) before you write into it. Open it as:
$fp = fopen( "filename.txt", 'a' );
if you want to add something to the end of the file without deleting the contents.
There are other options as well follow this to look them up:
http://www.php.net/manual/en/function.fopen.php
HTH