Writing specific lines of a text file
<p>I write this code:</p>

<pre><code>f = open('example.txt','r')
lines = f.readlines()

for i, line in enumerate(f):
if i &lt; 3:
   lines = ['LC '+line for line in lines]
   with open('./example.txt', 'w') as f:
      f.writelines(lines)
      f.close()
elif i &lt; 5:
    lines = ['LB '+line for line in lines]
    with open('./example.txt', 'w') as f:
        f.writelines(lines)
        f.close()
elif i &gt; 6:
    break

 f.close()
</code></pre>

<p>I have a file with 11 lines. I want to write something in the start from every line. The word is different for the 3 first line and different for other 2. Could you help me what am I doing wrong?</p>
