If “write” expects you to always call it in a loop, I wonder why it wasn’t simply implemented so that it calls itself in a loop in the first place. Or at least provide a “writeAll” wrapper function.
Callers would still need to be informed that a partial write occurred and would need to do something about it.