I read in the comments that a lot of people were having trouble
fw = open('sample.txt', 'w')
fw.write('Writing some stuff in my text file\n')
fw.write('I like bacon\n')
fw.close()
fr = open('sample.txt', 'r')
text = fr.read()
print(text)
fr.close()