I'd concur with
dragonchild, and add that
jesuashok's first suggestion, ordering within the sql output, may have issues but has some sense behind it.
You're going to the database separately for each @Geo_area. Maybe you're just picking out some (and not all) geo_areas, but perhaps then it makes more sense to do your filtering of these rows with a regex after you've done your select statement? Whether this makes sense probably depends on the number of rows being returned and the number of geographic areas (well, I'm guessing that's what they are) being investigated.
As for it not printing to an output file, check silly things like that the output file is open for writing, and that your query is actually returning any records. I notice you don't have any % signs bracketing your LIKE statement. Is this in the data, or is the LIKE really functioning as an
=?