Insert text at specific line python
<p>I am using the following code to insert  text on a line: </p>

<pre><code>exp = 82
with open ('test.txt','r') as b:
    lines = b.readlines()
with open('test.txt','w') as b:
    for i,line in enumarate(lines):
        if i == exp:
            f.write('test_data')
        f.write(line)
</code></pre>

<p>This inserts the text at line 82. How can modify it so that it can insert text at line 82 when it runs for the first time then line 83 the next time it runs, then line 84 etc. I was thinking of using a counter but I am unsure.</p>