title: Python tkinter saving to txt creates unusual empty row
body: <p>I am transferring an input in first listbox to second listbox. As you see in the first picture below, When I select &quot;dd&quot; in the first listbox, and press the &quot;Yapıldı&quot; button, it transferred to listbox below (second picture).</p>
  <p><a href="https://i.stack.imgur.com/deUlK.png" rel="nofollow noreferrer">first pic</a></p>
  <p><a href="https://i.stack.imgur.com/lwkVm.png" rel="nofollow noreferrer">second pic</a></p>
  <p>When I save second listbox to a file.txt. An error occurs. Before transferring &quot;dd&quot;, my file.txt is like that:</p>
  <pre><code>a
  b
  </code></pre>
  <p>After transferring &quot;dd&quot; and saving it to file.txt file. My txt file is like that:</p>
  <pre><code>a
  
  b
  dd
  </code></pre>
  <p>An empty row occurs in between a and b. Here is my code for transferring, and saving.</p>
  <pre><code>def select():
      textentry2.insert(END, textentry.get(ANCHOR))
      textentry.delete(ANCHOR)
  </code></pre>
  <p><strong>Note: textentry2 = second listbox widget, textentry =first listbox widget</strong></p>
  <pre><code>with open(&quot;file.txt&quot;, &quot;w&quot;) as file1:
      file1.close()
  with open(&quot;file.txt&quot;, &quot;r+&quot;) as file2:
      file2.write(&quot;\n&quot;.join(textentry2.get(&quot;0&quot;, &quot;end&quot;)))
  </code></pre>
  <p>I tried to clear my file.txt before saving, and write my second listbox to empty file.txt but still same one empty row error happens. I hope you can help me. Thank you</p>