Sorry for late response. I was super busy on some other work. So could not reply you on time. Hope you you got answer by this time. if not then You may post your code. I can help you. answer to question: There is nothing wrong. write function is there. Only thing is tempfile may get deleted based on which parameter you choose to create file.
you can write function to add content to file. If you will give more information about what content you are referring. Probably i can help better. Ex: filename = '/tmp/abc.txt' with open(filename, mode='w') as fh1: fh1.write('This is temp file') mode is 'w' . So file is not there then it will create or if exists then override it.