def ReplaceInFile(filename, old, new, encoding=None):
contents = GetFileContents(filename, encoding=encoding)<EOL>contents = contents.replace(old, new)<EOL>CreateFile(filename, contents, encoding=encoding)<EOL>return contents<EOL>
Replaces all occurrences of "old" by "new" in the given file.

:param unicode filename:
    The name of the file.

:param unicode old:
    The string to search for.

:param unicode new:
    Replacement string.

:return unicode:
    The new contents of the file.