with open('notes.txt', 'w') as file: file.write("This is a note.") print("File has been written and closed automatically.")