with open("files/vegetables.txt", "w") as myfile: myfile.write("Tomato\nCucumber\nOnion") myfile.write("\nGarlic")