# Open the file in write mode ('w')
aFile=open("outputFile.txt", "w")
aFile.write("Hello, Kenyon!\n") # Write something to the file created on the previous line
# Write another line to the file
aFile.write("This is an example of writing to a file in Python.\n")
aFile.close()
myFile2=open("outputFile.txt", "r") #open the file fpr reading
test2=myFile2.read()
print("Second:",test2)
myFile2.close()
myFile3=open("outputFile.txt", "a") #open the file for writing, this time append instead of overwrite
myFile3.write("Are you happy about the end of February? \n")
myFile3.close()
Hello, Kenyon!
This is an example of writing to a file in Python.
Are you happy about the end of February?