It has taken me an hour to get that little bit of code

to workaround the Windows limitation of not being allowed to overwrite a
file. :|