writeWord implementation