fixed write_words