I'm not sure if I get you either, but if I do, something like this would work:

VB Code:
  1. Do While Not EOF(1)
  2.     Line Input #1, strReadLine
  3.     If InStr(1, strReadLine, "S ") Then
  4.         If InStr(1, strReadLine, "/") Then
  5.             'Do some events
  6.         ElseIf InStr(1, strReadLine, "grep") <= 0 Then
  7.             Exit Do
  8.             'So unless there's "grep", it won't continue.
  9.         End If
  10.     End If
  11. Loop