Updated to resolve overlaps and write to output file
Included word boundaries