null character was ignored when using write() on some functions.