Link to home
Start Free TrialLog in
Avatar of jennifere
jennifere

asked on

Deleting header lines in text file

I am writing data to an appending text file.  However, each batch file that is written has a header line(these are all the same).  The first header line is fine, but I don't not want any more subsequent headers after that.  Here is the code I have now, but for some reason it is not deleting any of my header lines...  Any suggestions or other possible solutions?

Header= <COLUMNS>|OFFICE_ID|TERMINAL_ID|OFFICE_NAME|PHONE....>

Code:
Open "c:\officeOutput.txt" For Append As #2
       
 'delete extra header lines
 For i = 0 To UBound(lines)
    str = lines(i)
    If InStr(str, "COLUMNS") > 0 Then
        lines(i) = vbNullChar
    End If
Next

 'uses filter to delete lines
lines = Filter(lines, vbNullChar, False)

 'write data
For j = 1 To UBound(lines)
      Print #2, getField(j,1) + getField(j,2)+getField(j,3)....
Next

Close#2
SOLUTION
Avatar of aelatik
aelatik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jennifere
jennifere

ASKER

Okay, never mind.  I figured out the problem on my own.  I was writing my data to a collection and then trying to delete lines.  Anyhow, with a little bit of code rearrangement, it is working now.  I will go ahead and split the points because you both responded so quickly.  I appreciate it!  =)