I am writing an assignment for counting the number of vowels in a file, currently in my class we used only such code to check the end of the file:
vowel=0
f=open("filename.txt","r",encoding="utf-8" )
line=f.readline().strip()
while line!="":
for j in range (len(line)):
if line[j].isvowel():
vowel+=1
line=f.readline().strip()
But this time, for our assignment, the input file provided by our professor is a whole essay, so there are several empty lines in the text to separate paragraphs and something else, which means that my current code will be counted only up to the first empty line .
Is there any way to check if my file has reached the end besides checking for the presence of a line? Preferably similarly, I have my code now, where it checks something each iteration of the while loop
Thanks in advance