Mic wrote: > text_file.close It has to be text_file.close() to actually do something. > text_file=open(self.filename,"w") > text_file.write(self.filename) > text_file.close() Pro-tip: this can be simplified to with open(self.filename, "w") as text_file: text_file.write(self.filename)