almost working correctly, although for some reason still adds words with length of 0.