// }
// return -1L;
}
// TODO: handle errors in buffered write by retrying until finished or file is closed
return writeStream.fwrite(buffer);
// while (errno = 0, offset += (r = fwrite(RSTRING(str)->ptr+offset, 1, n, f)), (n -= r) > 0) {
// if (ferror(f)
// ) {
// if (rb_io_wait_writable(fileno(f))) {
// rb_io_check_closed(fptr);