Although this works, the code is doing two string comparisons per word, which is twice as much work as necessary, and will be costly if the text we are searching is large.