Is that output what you expected? All the arrays that were printed only have one word in them.
If there is only one word, then there is nothing to compare that one word against:if (words[j + 1].equals(word))
Also did you see Greg's post about the error you are getting? The for loop's index: j+1 is past the end of the array.
You forgot to print out the value of line after a record is read into it.