Readline() in a loop is not working in python <p>I have a file called <code>file</code> with this text:</p> <pre><code>Hello I am not a bot I am a human Do you believe me? I know you won't Yes I am a bot Yes you thought it right </code></pre> <p>This code prints out all the lines of the text:</p> <pre><code>with open(file) as f: for i in f: print(i,end="") </code></pre> <p>But this code does not, and I don't understand why.</p> <pre><code>with open(file) as f: for i in f: print(f.readline(),end="") </code></pre> <p>This prints out:</p> <pre><code>I am not a bot Do you believe me? Yes I am a bot </code></pre> <p>What I understand is as the loop goes over the lines in the file, it will read that line and return that as a string which is then printed. If I replace the for loop with <code>for i in range(9)</code>, it works.</p>