kludgy but at least manages to write an output now, can't handle inputs yet