Possibly another way
VB Code:
  1. Dim Prts() As String
  2. Dim txtFile As String
  3.  
  4. 'Read the file
  5. Open "D:\test.txt" For Input As #1
  6.     txtFile = Input(FileLen("D:\test.txt"), 1)
  7. Close #1
  8.  
  9. 'Split the text
  10. Prts() = Split(txtFile, vbCrLf)
  11.  
  12. 'If the last three lines are empty then remove them
  13. If Prts(UBound(Prts)) = "" And Prts(UBound(Prts) - 1) = "" And Prts(UBound(Prts) - 2) = "" Then
  14.     ReDim Preserve Prts(UBound(Prts) - 3)
  15. End If
  16.  
  17. 'Re put the parts back together
  18. txtFile = Join(Prts(), vbCrLf)
  19.  
  20. 'Write it back
  21. Open "D:\test.txt" For Output As #1
  22.     Print #1, txtFile
  23. Close #1