Removed use of the scanner and added a method that can read an input stream. Fixed reading body of response when an error occurs.