title: Incorrectly deleting last characters from file
body: <p>Within my subprocess, I want to remove the last 4 characters from every line in my txt file. However the lines are of varying length. I've seen a lot of pages including <a href="https://stackoverflow.com/questions/3675169/how-to-shave-off-last-character-using-sed">How to shave off last character using sed?</a> but nothing seems to be doing it correctly. I have about 100 lines and the first 38 don't remove the first 4 characters properly. A seemingly random number is removed. After those first lines, all lines after have my expected output. How? For now I have:</p>
  
  <pre><code>subprocess.run(['sed', 's/.\{4\}$//', 'infile.txt'])
  </code></pre>
  
  <p>The file always has four useless characters at the end - <strong>/pid</strong>:</p>
  
  <pre><code>3726-weinberg/pid
  11717-christopher/pid
  11138-span/pid
  .
  .
  .
  2932-smith/pid
  .
  .
  .
  </code></pre>
  
  <p>The problem is that the output is:</p>
  
  <pre><code>3726-w
  11717-chri
  111
  .
  .
  .
  2932-smith //line 39! all good now
  .
  .
  .
  </code></pre>
  
  <p>but I expected:</p>
  
  <pre><code>3726-weinberg
  11717-christopher
  11138-span
  .
  .
  .
  2932-smith //line 39! all good now
  .
  .
  .
  </code></pre>
  
  <p>Sed need not be the solution. If truncate or cut or any various other options work too feel free to let me know. I chose sed because I use it in another part of the program.</p>