use vbscript to modify a text file
Every day we get a flat text file.  Some days there are lines in the file that need to be deleted before it can be processed.  These lines can appear in different places, but always start with the characters 6999 or 7999.  We would like to run a script that will delete these particular lines.  However, and this is way beyond me, any where there is a line that starts 6999 there will be a line immediately before it that starts 5442 that also needs to be deleted, but only if it appears immediately before the 6999 line.

We are a Windows shop and would run this script as part of a simple batch file in Windows.  We do not use Unix or Linux nor desire to.

The file name extension reflects the date.  today's file is file.100621, tomorrow's will be file.100622.  I am having trouble with this aspect, as it seems vbscript does not like file.*

Here is a sample of the text file:
4006006602    03334060000100580                                                 
40060066039    0334070000100580                                                 
700600000011571006210060001255863                                               
544264287250111000025000000000040008000801                                      
6999001000000000000000000000000000000000000000000000000000                      
6999001000000000000000000000000000000000000000000000000000                      
6999001000000000000000000000000000000000000000000000000000                      
799900000011571006210030000000000                                               
8007000000115710062102530054008920                                              

we'd like to remove 5 lines in this file (the 5442 line, the three 6999 lines, and the 7999 line).

here is a sample of the script that I found on this site, have modified and had some success, but don't know the way to delete the lines (only know how to replace data in the line).  I realize this will either need major modifications or need to be thrown out altogether, but I post this to provide an idea of what i think we are looking for. I put this in a directory with the cscript.exe and call it from a simple batch file:
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\temp\file.100621"
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    If InStr(strLine,"6999")> 0 Then
        strLine = Replace(strLine,"6999","delete line")
    End If 
    WScript.Echo strLine
Loop

which gets me this:
40060066039    0334070000100580                                                 
700600000011571006210060001255863                                               
544264287250111000025000000000040008000801                                      
delete line001000000000000000000000000000000000000000000000000000                      
delete line001000000000000000000000000000000000000000000000000000                      
delete line001000000000000000000000000000000000000000000000000000                      
799900000011571006210030000000000                                               
8007000000115710062102530054008920  

Close! just need to delete lines instead of write "delete line".
So here are my specific needs based on what I know:
1. get the script to process any file in the directory (and there will only ever be 1 at a time, but the extension changes every day) 
2. get the script to delete any line that starts with a 5442 that is immediately before a line that starts 6999
3. get the script to totally those lines that start with 6999 and 7999

Thanks in advance for any and all help!
use vbscript to modify a text file
===

Every day we get a flat text file.  Some days there are lines in the file that need to be deleted before it can be processed.  These lines can appear in different places, but always start with the characters 6999 or 7999.  We would like to run a script that will delete these particular lines.  However, and this is way beyond me, any where there is a line that starts 6999 there will be a line immediately before it that starts 5442 that also needs to be deleted, but only if it appears immediately before the 6999 line.

We are a Windows shop and would run this script as part of a simple batch file in Windows.  We do not use Unix or Linux nor desire to.

The file name extension reflects the date.  today's file is file.100621, tomorrow's will be file.100622.  I am having trouble with this aspect, as it seems vbscript does not like file.*

Here is a sample of the text file:
4006006602    03334060000100580                                                 
40060066039    0334070000100580                                                 
700600000011571006210060001255863                                               
544264287250111000025000000000040008000801                                      
6999001000000000000000000000000000000000000000000000000000                      
6999001000000000000000000000000000000000000000000000000000                      
6999001000000000000000000000000000000000000000000000000000                      
799900000011571006210030000000000                                               
8007000000115710062102530054008920                                              

we'd like to remove 5 lines in this file (the 5442 line, the three 6999 lines, and the 7999 line).

here is a sample of the script that I found on this site, have modified and had some success, but don't know the way to delete the lines (only know how to replace data in the line).  I realize this will either need major modifications or need to be thrown out altogether, but I post this to provide an idea of what i think we are looking for. I put this in a directory with the cscript.exe and call it from a simple batch file:
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\temp\file.100621"
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    If InStr(strLine,"6999")> 0 Then
        strLine = Replace(strLine,"6999","delete line")
    End If 
    WScript.Echo strLine
Loop

which gets me this:
40060066039    0334070000100580                                                 
700600000011571006210060001255863                                               
544264287250111000025000000000040008000801                                      
delete line001000000000000000000000000000000000000000000000000000                      
delete line001000000000000000000000000000000000000000000000000000                      
delete line001000000000000000000000000000000000000000000000000000                      
799900000011571006210030000000000                                               
8007000000115710062102530054008920  

Close! just need to delete lines instead of write "delete line".
So here are my specific needs based on what I know:
1. get the script to process any file in the directory (and there will only ever be 1 at a time, but the extension changes every day) 
2. get the script to delete any line that starts with a 5442 that is immediately before a line that starts 6999
3. get the script to totally those lines that start with 6999 and 7999

Thanks in advance for any and all help!