Added better error checking and moved get_file_contents to reduce calls to NWS server