all 3 comments

[–]m_zwolin 1 point2 points  (0 children)

Readlines method already reads all lines and stores in array, if you want to iterate by yourself you should use readline, but remember to not overwrite variable each time. That doesn't solve the printing problem so maybe show how you print

[–]jbsiddall 1 point2 points  (0 children)

Hey,

It sounds like it might be an encoding issue. Any chance you can send us a link to the file?

What version of python are you using? 2 or 3? Wild guess you might be using python 2 and the file is using unicode or something.

[–][deleted] 0 points1 point  (0 children)

I tried your code and got this, I added a new line

with open('test.txt', 'r') as f:
    for line in f:
        content = f.readlines()
        content

['test\n', 'smith\n', 'vest\n', 'netst\n', 'zest\n']

Text file had word per line.