I guess what I would do is open file A for reading, and file B for writing. Read from file A, line by line - if the line doesn't contain the string you're looking for, then just write the line to file B - if the line does contain the string you're for, then write the "changed" line to file B.
You end up with file B which is the same as file A, except that the string you were looking for has been found and changed in file B.
When that loop has finished, you can "move" file B to file A - you basically want to remove the original file A, and rename file B to file A. There are at least a few ways to accomplish that.
As you're writing your code, test it along the way. If you have trouble with a specific part, post your problem and someone can help you.
HTH. Hardy Merrill