here is an example.
$text = file_get_contents("./file.txt");
$insert = "somestring\ngoes\nhere\n";
$text = substr($text, 0, 80) . $insert . substr($text, 81);
$fp = fopen("./file.txt", "w+");
fwrite($fp, $text);
fclose($fp);
use substr to capture part of a string. "insert" your new data into whatever part you want. you can use fseek to move the file pointer when you use fopen, but if you write to a file before its end, it will overwrite the data, not move it. much like typing on your computer with the insert key turned on.