Actually, I think you do get the word twice. It just happens to be discarding the first occurrence read on line 13 and immediately overwritten on line 14, before the testing begins.
EDIT: That is assuming that your data file starts with cat on line 1, like this: