Why following code doesn't work?
<pre><code>fin = open('/abc/xyz/test.txt', 'a+')

def lst():
  return fin.read().splitlines()

print lst()

def foo(in):
  print lst()
  fin.write(str(len(lst()) + in)
  fin.flush()
</code></pre>

<p>In above code when <code>print lst()</code> is called outside function it gives correct result, but when trying to call same funtion in function <code>foo()</code> it produces empty list which makes <code>len(lst())</code> value 0. I also tried by commenting last two line but still it gives back empty list. What is wrong in above code?</p>
