not working - need to work out how to re-read the output stream