So, you should be closing these files at the end of this function, and it's best to wrap them in a "try/finally" block and put the closes in the "finally", BUT, the sweetest way to accomplish this is:

```
with open(<path>, <mode>) as my_file:
    my_file.write("blah blah blah)

```

Now, since you have two files that you want to open, you can do:

```
with open(os.path.join(self._osi, 'monarch_xp.bat'), 'wb') as new_prof,
       open(os.path.join(self._osi, 'scripts', 'monarch_xp.bat'), 'rb') as old_prof:

    # write your code here, when the with block exits, it will close your file handles

```
Also notice int he code above i changed "w+" to "wb" which means write-binary, a MUST on windows if there is binary data in the file, or else it will interpret a 0 as the end of the file.