Updated file_replace() method to work on Windows and Python 3