Check return state of write(), otherwise this fails for compilers for un...

If you have the unused flag set and you don't check the return value of write() the compiler will complain at you.