I found this code and it post data at the top of a text file, works great, but I dont understand it...
function write_beg($filename, $data)
{
//Imports old data
$handle = fopen($filename, "r");
$old_content = fread($handle, filesize ($filename));
fclose($handle);
//Sets up new data
$final_content = $data.$old_content;
//Writes new data
$handle2 = fopen($filename, "w");
$finalwrite = fwrite($handle2, $final_content);
fclose($handle2);
thanks