Starting with an empty cross-reference table and the current line number at one, repeatedly get tokens until there are no more. For each token:
After reading the entire input, print the alphabetized cross-reference listing, one word per output line.
- If that token is a word, add an entry to the cross-reference table containing that word and the current line number.
- If that token is a newline, increment the current line number.