I have a .txt file with 10 sort lines of text (three comma separated words each), but the following only reads four of the lines in the text file:
def main():
path = '/path/to/file.txt'
f = open(path, 'r')
for line in f:
s = f.readline()
print(s)
f.close
main()
but this will read all the lines but into a list:
def main():
path = '/path/to/file.txt'
f = open(path, 'r')
s = f.readlines()
print(s)
f.close
main()
Why doesn't the for loop work?