As I already stated, s would be used on purpose by someone who knows the match would start with that word and that they don't want something that has that word somewhere in the line or has just that word in the line. For the purpose of that example, it is correct.
If you wanted it to match wherever the word was, or if the word was the only thing in the line, then you would use a wildcard search, as I already said...
var %test = $iif($read(test.txt,w,*word*).line,$v1)
var %test = $iif($read(test.txt,w,*word*),$readn)
Let's see now...
This is a text file.
It has a
word in it.
Line 2 is the one we want.
The first one will search for *word* and will find it in line 2 and with the .line property, $v1 will be the line number of the matching text... line 2. Agreed?
The second one will search for *word* and will find it in line 2. $readn will be the last line read... line 2. Agreed?
They both give the same results.
If all you are saying is that with s used, if a line has only that one word on it, that it won't be right... ok.... If a person CHOOSES to use s, then they better know how it works. There are reasons a person would WANT to see $null if the word was the only thing on the line. If they didn't want that, then they would use w to search instead.
But regardless, the code is correct for what it was intended. s may not be ideal for what one person might want and they might prefer w instead... for others, it might be exactly what they want.