perl -nle '/(\w*)/;$i{$1}++;print for keys %i;' words.txt