myfile = open("temp.txt", "w")
myfile.write("Ez egy szöveg \n\tegy fájlban, \n\t\tamit a program írt ki.")
myfile.close()

myfile = open("temp.txt", "r")
while True:
    line = myfile.readline()
    if len(line) == 0:
        break
    print(line, end="")
myfile.close()

print("")
myfile = open("temp.txt", "r")
linelist = myfile.readlines()
myfile.close()
for line in linelist:
    print(line, end="")

print("")
myfile = open("temp.txt", "r")
full = myfile.read()
myfile.close()
print(full)

with open("temp.txt", "r") as myfile:
    full = myfile.read()
    print(full)
# file.close() nem szükséges, a "with" bezárja a végén a fájlt.

words = full.split()
print("A fájl {0} szót tartalmaz.".format(len(words)))
