Cannot generate root output file

Please see the pinned post on How to post code snippets as it’s rather difficult to make sense of the code. I’d note that this looks more like a problem with the script or Gate, but if the main.mac file mentioned is using paths, please post that as well.