Reading changing file in Python 3 and Python 2
<p>I was trying to read a changing file in Python, where a script can process newly appended lines. I have the script below which prints out the lines in a file and does not terminate.</p>

<pre><code>with open('tmp.txt','r') as f:
    while True:
        for line in f:
            print(line.replace('\n',''))
</code></pre>

<p>Where 'tmp.txt' consists of some lines, e.g.:</p>

<pre><code>a
d
2
3
</code></pre>

<p>If I appended to the 'tmp.txt' file, such as using:</p>

<pre><code>echo "hi" &gt;&gt; tmp.txt
</code></pre>

<p>The script will print out the new line in if the script is run with Python 3, but not with Python 2. Is there an equivalent in Python 2? And what's different between the two versions of Python in this case?</p>