Fixed duplicate words

The score() function assumed that foreach went through the array in
order--this appears not to be the case.