well... You don't even exit from main thread if write will fail this way.

What the reason of such error handle? I would better just ignore result...