title: responsive way to write in a specific line in python?
body: <p>I know that reading a specific line is possible with:</p>
  <pre class="lang-py prettyprint-override"><code>i = 0
  while True:
      with open(&quot;file.txt&quot;) as f:
          f = f.readlines()[i]
      i += 1
  </code></pre>
  <p>So I wondered if there is any responsive way to write to a specific line, but this doesn't seem to be working:</p>
  <pre class="lang-py prettyprint-override"><code>i = 0
  while True:
      with open(&quot;file.txt&quot;, 'w') as f:
          f = f.writelines(str(episode))[i]
      i += 1
  </code></pre>
  <p>But this alone does work:</p>
  <pre class="lang-py prettyprint-override"><code>with open(&quot;file.txt&quot;, 'w') as f:
      f = f.writelines(str(episode))
  </code></pre>