boolean empty = buf == null || buf.length() == 0;
ByteList newBuf = empty ? ByteList.EMPTY_BYTELIST.dup() : buf;
string.view(newBuf);
if (stream.feof() && empty) return runtime.getNil();
return string;
} catch (BadDescriptorException e) {
throw runtime.newErrnoEBADFError();
} catch (InvalidValueException e) {