If you're looking to prepend the information to the file (place it at the start, not at the end, and keep all the old information), you could store the information in an array and then write the array to the file:
<?php
$lines[] = "first new line";
$lines[] = "second new line";
$lines[] = "end of new information - just another line";
$filename = '/path/to/file.txt';
$in = fopen( $filename, 'r' );
while( !feof( $in )) {
$lines[] = fgets( $in, 1024 );
}
fclose( $in );
$out = fopen( $filename, 'w' );
foreach( $lines as $line ) {
fputs( $out, $line );
}
fclose( $out );
?>
Essentially, this script starts to populate an array $lines with your new data, then the old data in the file is appended to the new data.
At that point, the whole array, with new data at the beginning and old data at the end is written back out to the file.
This should work for you. There may be a more elegant way to do it (there are many ways to do the same thing in most languages), but this should work just fine for you.
Hope this helps!
-Rich