
February 3rd, 2012, 10:48 AM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 6
Time spent in forums: 1 h 45 m 47 sec
Reputation Power: 0
|
|
|
Problem with "If line is None: break"
I am trying to get read a line of a text file one by one by using the following statements:
Code:
f = open("numbers.txt", 'r')
while True:
line = f.readline()
if line is None:
break
The problem is that it is not breaking when it reaches the end of the last line of the text file but instead goes into an infinite loop.
Could someone please explain to me what I am doing wrong? 
|