title: How do you delete empty lines from a textfile
body: <p>I am trying to delete empty lines from a textfile using vb.net. This is an example of what I have tried so far however it is not working as expected:</p>
  
  <pre><code>Dim i As Integer = 0
      Dim CountDeleted = 0
      Dim TextString As String
  
      For Each Line As String In lines
          TextString = lines(i)
          If TextString.Trim = "" Then
              lines.RemoveAt(i)
              CountDeleted += 1
          End If
          i += 1
      Next Line
  </code></pre>
  
  <p>This is an example of the data within a textfile that I would like to remove the lines from:</p>
  
  <pre><code>BUSINESS_UNIT|PO_ID|LINE_NBR|CANCEL_STATUS|
  
  A
  
  B
  C
  </code></pre>
  
  <p>Required output:</p>
  
  <pre><code>BUSINESS_UNIT|PO_ID|LINE_NBR|CANCEL_STATUS|    
  A
  B
  C
  </code></pre>
  
  <p>Any help would be much appreciated </p>