Helper function to read InputStream data.