infile = 'xyz.txt'
f = open(infile)
line = f.readline() # these lines are all read fine
print("line=",line)
line = f.readline()
print("line=",line)
line = f.readline()
print("line=",line)
pause()
f.close()
with open(infile) as f:
line = f.readline() # this reads the first line but
print("line=",line) # dies without a message on line 2
pause()
sys.exit
def pause():
c = input("\nEnter q to quit, anything else to continue\n")
if (c.lower()=='q'): sys.exit()
return (c)
Adding arguments to open, like 'r', 'ignore', encoding, etc. make no difference.
It happens on other input files as well, so it's not input specific.
It dies even without the pause in the loop
After the first line, it prints the line and the pause message, and dies reading the second line.
Could this be a genuine compiler error?