Refactor HANDLE_CASE(write()) to swrite

swrite means safe write.