Moving DOM write to outside of loop (better performance)

When testing with a couple of hundred words (extreme case but easier to see the difference) this cut the load time from around 5 seconds back down to around 1.