I think I have found a problem in the FileSearch function - on exit $0 and $1 variables are swapped when compared on their settings on entry to the function.
I think that this can be fixed by changing the end of the FileSearch function from:
Exch $2 ;output number of linesto:
Exch 2
Exch $1 ;output yes/no
Exch
Exch $0 ;output count found
FunctionEnd
Exch $2 ;output number of linesRegards
Exch 2
Exch ; Add this line
Exch $1 ;output yes/no
Exch
Exch $0 ;output count found
FunctionEnd
Tim