title: python reading .txt file, cant remove newline characters
body: <p>im trying to figure out why it wont let me remove the newline characters, my code:</p>
  
  <pre><code>    def parsefile(f):
        for line in open(f):
              li=line.strip()
              if not li.startswith("%"):
                  if not li.startswith(' '):
                      if not li.startswith('\n'):
  
                   print(line.replace("\n",""))
                     #print(line.rstrip())
  </code></pre>
  
  <p>even though i have told it to ignore the '\n' is still leaving spaces in the output, which looks like this</p>
  
  <pre><code>    type1
  
      type2
      type3
  
      type4
  </code></pre>
  
  <p>when it should just be  </p>
  
  <pre><code>       type1
         type2
         type3
         type4
  </code></pre>
  
  <p>. my guess is its something to do with my loop leaving the spaces.</p>
  
  <p>the file im accessing is:</p>
  
  <pre><code>    %spam 
  
      type1
      type2
      type3
  
      %spam
      type4
  </code></pre>