Fix INPUT and OUTPUT reading