check for those function :
strpos(string text1, string text2)
substr(string text, int beginning, int length)
strlen(string text)
descFile = fopen(string fileName, string mode)
fgets(int descFile, int length)
fclose(int descFile)
You should be able to do what you want to do with those function. Open your file, read it, and then with the string function, you cut your text and add another content a the end like that :
$test = "this is a beautiful, ";
$test . "half moon";
Hope that helps,
Jacinthe