Problem z ponownym wywołaniem funkcji

0

Witam
Napisałem taki oto skrypt i mam pytanie dlaczego drugi printFile nic nie wypisuje.

def printFile(name):
	"""print file """
	for line in name:
		print(line, end='')

f = open('workfile.txt', 'r')
print("Print file first time:")
printFile(f)

print("Print file second time:")
printFile(f)
 

Uruchomienie skryptu daje takie wyjście:
Print file first time:
First line of the file.
Second line of the file.

Print file second time:

1

Po pierwszym drukowaniu jesteś na końcu pliku. Przesuń wskaźnik na początek pliku.

printFile(f)
 
f.seek(0)
printFile(f)

1 użytkowników online, w tym zalogowanych: 0, gości: 1