title: python remove last comma
body: <p>I have some thing like this in output.txt file</p>
  
  <pre><code>Service1:Aborted
  Service2:failed
  Service3:failed
  Service4:Aborted
  Service5:failed
  </code></pre>
  
  <p>output in 2nd file(output2.txt) :</p>
  
  <pre><code> Service1        Service2   Servive3   Service4     Service5
   Aborted         failed     failed     Aborted      failed
  </code></pre>
  
  <p>Would like to remove the last comma in the line.</p>
  
  <p>Code I am trying:</p>
  
  <pre><code>    file=open('output.txt','r')
      target=open('output2.txt','w')
      for line in file.readlines():
            line=line.strip()
            parts=line.split(":")
            for part in parts:
                 var2=part.strip()+","
            target.write(var2.rstrip(','))        # Not working
     target.close()
  </code></pre>