I have written a little class which reads a text file and which have a method for printing the text (file.output()). For the first call it worked, but the second call of the method nothing is happening. I do not understand why, since I assume that the FOR-Loop does not change anything.
class Datei():
def __init__(self, filename):
self.fileobject = open(filename)
def output(self):
for line in self.fileobject:
print(line.rstrip())
def end(self):
self.fileobject.close()
file = Datei("yellow_snow.txt")
file.output()
print("second try")
file.output()
file.end()
I expected the text of the text file to be printed twice, but it is only printed once.