title: Python - Delete a part of each line of a textfile
body: <p>I have a text file like this:</p>
  
  <pre><code>abc123bvjhfvb:dlnvsl|smth
   fsbffsb378hbdcbs:v5v3v|smth
   sdcg87wgn8:vy5b4|smth
   sin87s88vnus:y54545v4v|smth
   rc8n782c:efghrn|smth
  </code></pre>
  
  <p>As you can see there is a space starting from the second line.</p>
  
  <p>How can I convert these lines to these?</p>
  
  <pre><code>abc123bvjhfvb:dlnvsl
  fsbffsb378hbdcbs:v5v3v
  sdcg87wgn8:vy5b4
  sin87s88vnus:y54545v4v
  rc8n782c:efghrn
  </code></pre>
  
  <p>I tried something like this:</p>
  
  <pre><code>lines = open("file.txt").readlines()
  
  for x in lines:
      x.strip(" ").split("|")
      print (x[0])
  </code></pre>
  
  <p>But it prints only the "a" of abc123 and then a series of space for each line. I think the [0] goes to print the first letter instead of printing the first part of split before the "|" (for example abc123bvjhfvb:dlnvsl)</p>