# This will open a new file called myFile.txt and
# write 0 - 4 using a loop, each on a new line.
# Note the "
" part!
with open("myFile.txt", "w") as file:
for i in range(0,5):
file.write(str(i) + "
")
# We do not need to use "file.close()" because
# we used "with open(...)" which is considered
# to be more "pythonic"
file = open("sample.txt", "w")
file.write("Hello
")
file.write("World
")
file.close()
f=open('output.txt', 'w')
print("Hello world", file=f)
f.close