1for file in files:
2 fname = os.path.join(dir, file)
3 inFile = codecs.open(fname, "r", "utf-8")
4 outFile = codecs.open(fname + ".new", "w", "utf-8")
5 for line in inFile:
6 newline = do_replacements_on(line)
7 outFile.write(newline)
8 inFile.close()
9 outFile.close()
10 os.rename(fname + ".new", fname)
11