Addition, if the file is very large, read the original file line by line and write the modified lines to a temp file, delete the original and rename temp to original.