Thank you Ken. I limited the search terms to 500 and that program you wrote, while it works flawlessly, has been running over an hour and still going. I don't know when it will end.
Interestingly enough this command processes all search terms and the complete file in 3 minutes 24 seconds.
time grep -P 'Z' file_to_search | awk '{print $1}' | sort | uniq --count > uniq.count