title: How to convert the : char into a newline in a file by python
body: <p>I am having a text file in which data is in this form: </p>
  
  <p>Before formatting:</p>
  
  <pre><code>a1 ,a2,a3:b1 ,b2,b3:c1 ,c2,c3:....so on. 
  </code></pre>
  
  <p>Now i want to convert the data in this particular form:</p>
  
  <p>After formatting:</p>
  
  <pre><code>a1,a2,a3
  b1,b2,b3
  c1,c2,c3
  ...so on
  </code></pre>
  
  <p>To do: first i want to convert <code>:</code> char in 'newline' and want to recover the space after every first character such as <code>a1 b1 c1</code>. the space is creating problem as the data after formatting is to be converted into csv file.</p>
  
  <p>I tried transferring one by one char from one file to other in which i used an if case to replace <code>:</code> to 'newline'.
  For newline I used this <code>\n</code></p>
  
  <p><code>file.txt</code> is file which contain <code>a1 ,a2,a3:b1 ,b2,b3:c1 ,c2,c3:....so on</code></p>
  
  <p><code>convert.txt</code> if file in which i want formatted data</p>
  
  <pre><code>with open('file.txt','r') as rf:
      with open('convert.txt','w') as wf:
          a=1
          rf_temp = rf.read(a)
          while len(rf_temp) &gt; 0:
              if rf_temp == ':':
                  rf_temp.replace(':','\n')
              wf.write(rf_temp)
              rf_temp = rf.read(a)
      wf.close()
  rf.close
  </code></pre>
  
  <p>the data gets copied clearly but not in format which i want including ':' this symbol.
  There are no issues in copying.</p>