exit properly when input stream goes bad.