title: Python printing output to file adds extra blank line
body: <p>I'm writing a simple program that replaces one word of a text file with the word &quot;banana.&quot; Here is how it is currently structured:</p>
  <pre><code>file = filedialog.askopenfilename(initialdir=&quot;/Users/Alex/Desktop&quot;, title=&quot;Open File&quot;, filetypes=((&quot;TXT files&quot;, &quot;*.txt&quot;), ))
  for line in fileinput.FileInput(file,inplace=1):
      if 'sports' in line:
          temp = line.split()
          rep = temp[0]
          line = line.replace(rep, &quot;Banana&quot;)
      print(line)
  </code></pre>
  <p>The word is replaced as intended, however whenever I check the new file, there is a blank line between each line of text. It should look like this:</p>
  <pre><code>Cats are cute.
  Banana enjoy sports.
  I like to wear jackets.
  Green is my favorite color.
  </code></pre>
  <p>But instead, it looks like this:</p>
  <pre><code>Cats are cute.
  
  Banana enjoy sports.
  
  I like to wear jackets.
  
  Green is my favorite color.
  
  </code></pre>
  <p>How can I get rid of the blank line between each line of text in the file?</p>