handling connection error; writing files for every search term; some minor fixes