title: Getting an Extra Empty line when exporting Excel Range to .txt file
body: <p>I am trying to copy an Excel range to a .txt file.</p>
  
  <p>The export is successful, with one exception, It adds one "<strong>extra</strong>" empty line at the end.</p>
  
  <p>I've read and tests many of the solution on <strong>SO</strong> (and other sites), but still without any success.</p>
  
  <p><strong>My Code</strong> (relevant part)</p>
  
  <pre><code>' === Export to the .txt file ===
  Dim TxtFileName As String, lineText As String
  
  TxtFileName = ThisWorkbook.Path &amp; "\Inv_" &amp; Format(Date, "yyyymmdd") &amp; ".txt"
  
  Open TxtFileName For Output As #1
  With StockSht
      For i = 1 To LastRow
          For j = 1 To 3
              If j = 3 Then
                  lineText = lineText &amp; .Cells(i, j).Value2
              Else ' j = 1 or 2
                  lineText = lineText &amp; .Cells(i, j).Value2 &amp; vbTab
              End If
          Next j
          Print #1, lineText
          lineText = ""
      Next i
  End With
  Close #1
  </code></pre>
  
  <p>My <code>StockSht</code> (worksheet object) and <code>LastRow</code> are defined correctly, and getting their values.</p>
  
  <p><em>Screen-shot of the end of the exported .txt file</em></p>
  
  <p><a href="https://i.stack.imgur.com/ctkIl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ctkIl.png" alt="enter image description here"></a></p>