Hi Gunter Herd,
Sorry for super late reply. I hope you have figured it out by now, but if not, one of the reasons it might error out is because the directory you are trying to create the file in, does not exist. Python will not create the directory automatically (it will, however, for the file itself). So you need to ensure that the directory exists.
You can do something like
os.path.exists(directory) to check whether the directory exists, and if not, create it