Here is an example that may be useful...
$filename = file.rtf";
if(!($fp= fopen ($filename, "r"))) die ("Can't open file 1");
$Contents = file_get_contents($filename);
fclose ($fp);
//Replacefields
$newContents = str_replace ($badstring, $godstring, $Contents);
// re-save the file as an rtf...