A lot of this logic disappears in the face of the new buffered reader and buffered writer interface. This is passing ast-check only; semantic analysis to be solved next.