Generate the file in a separate folder (that should be empty) and move it to the main folder right after generation (which will make the other folder empty again for next use).
When you move, you have the option to overwrite the file if it already exists.