Here's a basic approach. Read in each line and use a StringTokenizer to break it into individual words, saving the words in a list (e.g., ArrayList). Then loop through the list searching for the longest
word. Remove the longest word from the list and write out the remaining ones in the output file. Continue until all lines have been processed.