title: Rollup lines by delimiter count via Python
body: <p>I have a huge '|' separated file. There are certain lines which have broken into two and shifted to the next line. Given , I know the number of delimiters in each line (say 100) how do I append this to the first half to get the whole correct record.</p>
  
  <p>I have tried the below but it does not work as expected :</p>
  
  <pre><code>with open(file_name) as f:
      for line in f:
          lis.append(line)
  
  file_object=open(out_file,'w+')
  for x in range(len(lis)):
      line=lis[x]
      delim_count=line.count('|')
      if(delim_count==100):
          file_object.write(line)
      elif(delim_count&lt;100):
          `file_object.write(lis[x]+lis[x+1])        
      x=x+1
  file_object.close()
  </code></pre>