try {
OpenFile myOpenFile = getOpenFileChecked();
myOpenFile.checkWritable(context.getRuntime());
Stream writeStream = myOpenFile.getWriteStream();
writeStream.fputc(RubyNumeric.num2chr(object));
if (myOpenFile.isSync()) myOpenFile.fflush(writeStream);
} catch (IOException ex) {
throw context.getRuntime().newIOErrorFromException(ex);
} catch (BadDescriptorException e) {
throw context.getRuntime().newErrnoEBADFError();