try this:
$mefile = fopen("file.txt","r"

;
$readin = fread($mefile,filesize("file.txt"

);
fclose($mefile);
$mefile = fopen("file.txt","w"

;
for($i=0;$i<count($readin);$i++)
{
if($readin[$i] == "john"

{
$readin[$i] = "joe";
}
fwrite("$readin[$i]\n"

;
}
fclose($mefile);
basically, you've pulled the info out of the file, searched throughthe array element by element and found the one u want, replaced it with the string u wanted, and then over-writtern the original file with the old elements, and the new one, in order.
cheers
Siberd
mail: siberdude@ntlworld.com
ICQ: 44167565