I fixed the issue, thanks Alexey.
It was indeed trying to write to the Program Files directory and not the directory where the project was saved.
My solution is to prompt the user to select a path which will then be the default save path:
path = Metashape.app.getExistingDirectory("Where to save coords")
and then from within my function:
file = open(path+'\coord_list.txt', 'w')