Optimize string concatenation for word frequency analysis.