This is a side effect of how Caché finds the string, the code performs a read() on the stream to load a chunk into memory before searching for the string.

The read() is setting the AtEnd property, but if the string being searched for appears more than once in the chunk in memory, only the first occurrence will be found.

So in order to read all occurrences of the string, you should not sue the AtEnd to determine when to Stop.

The following code will count the number of times "Invalid password" appears in the file.

kill
set stream=##class(%Stream.FileCharacter).%New()
do stream.LinkToFile("d:\csp.log")
set x=""
set i=0
set j=0
write stream.Rewind()
while(i'=-1){set i=stream.FindAt(-1,"Invalid password",.x) set j=j+1}
write i
write j

 

Obviously you can alter the code in the while loop to perform any other action when it finds the string.