my %ad;
 
 for my $line ( <STDIN> ) {
-
   if ($line =~ /^\s*$/) {
-    # print out the hash
+    # print out the previous add sorted by key then reset the hash for a new ad.
     if (%ad) {
        for (sort keys %ad) { print $_; }
        undef %ad;
     }
   }
   $ad{$line} = 1;
-
 }
 
+# print the last ad sorted by key
 if (%ad) {
    for (sort keys %ad) { print $_; }
    undef %ad;