modify writeWord