Fix bug causing only 1 word to be written