code:
<?
$file='file.txt';
$newcontent = 'blah';
$new = $newcontent . "\n" . file_get_contents($file);
$fp =fopen($file,'w');
fwrite($fp, $new);
fclose($fp);
?>
you cant use fopen to write to the top without over writing. Use this to get the file contents add it to the end of the new string then save