What would the code look like for your suggestion to write to a temp file and then rename?
I got the old new replacements to work now by removing the quotes in my two open statements.
I am still having an issue with my loops. When I run the script it touches every file found two times (not necessary) and I am not sure how I told it to do that.
Also it is not advancing to the next line in the master file as the print line in the output is not showing the ip address from the second line. Only the first line all the way down.