title: Ways to read/edit multiple lines in python
body: <p>What i'm trying to do is to take 4 lines from a file that look like this:</p>
  
  <pre><code>@blablabla
  blablabla #this string needs to match the amount of characters in line 4
  !blablabla
  blablabla #there is a string here
  </code></pre>
  
  <p>This goes on for a few hundred times.</p>
  
  <p>I read the entire thing line by line, make a change to the fourth line, then want to match the second line's character count to the amount in the fourth line.</p>
  
  <p>I can't figure out how to "backtrack" and change the second line after making changes to the fourth.</p>
  
  <pre><code>with fileC as inputA:
      for line1 in inputA:
          line2 = next(inputA)
          line3 = next(inputA)
          line4 = next(inputA)
  </code></pre>
  
  <p>is what i'm currently using, because it lets me handle 4 lines at the same time, but there has to be a better way as causes all sorts of problems when writing away the file. What could I use as an alternative?</p>