Use Rio.write to simplify output
Fix NPE caused by Rio.write change