Index: trunk/BNC/scripts/Common.pm
===================================================================
--- trunk/BNC/scripts/Common.pm	(revision 10098)
+++ trunk/BNC/scripts/Common.pm	(revision 10099)
@@ -54,5 +54,5 @@
     eval { mkpath($dir) };
     if ($@) {
-        warn("Could not create path [$dir]: $@");
+        warn ("Could not create path [$dir]: $@");
         return 0;
     }
@@ -129,11 +129,12 @@
                 # could not replace -> append
                 blurt( "$newPos\n", $idxFil, { append => 1 } );
-#                my $INP;
-#                if ( !open ( $INP, ">>", $idxFil ) ) {
-#                    ERROR("Could not append file [$idxFil]: $!");
-#                    return 0;
-#                }
-#                print $INP "$newPos\n";
-#                close ($INP);
+
+                #                my $INP;
+                #                if ( !open ( $INP, ">>", $idxFil ) ) {
+                #                    ERROR("Could not append file [$idxFil]: $!");
+                #                    return 0;
+                #                }
+                #                print $INP "$newPos\n";
+                #                close ($INP);
             }
         }
@@ -141,4 +142,5 @@
             # initial write
             blurt( "$newPos\n", $idxFil );
+
             #writeTextInFile( $idxFil, "$newPos\n" );
         }
@@ -230,4 +232,5 @@
         if ( !exists $rcd->{'tags'}->{$_} ) {
             $err++;
+
             #next; # ?
         }
@@ -238,9 +241,11 @@
 
     # Fields
-    while ( my ( $k, $v ) = each %{ $rcd->{'fields'} } ) {
-        if ( !defined $v ) {
+    foreach ( sort { lc ($a) cmp lc ($b) } keys %{ $rcd->{'fields'} } ) {
+        if ( !exists $rcd->{'fields'}->{$_} ) {
             $err++;
-        }
-        $str .= $k . "=" . $v . ",";
+
+            #next; # ?
+        }
+        $str .= $_ . "=" . $rcd->{'fields'}->{$_} . ",";
     }
     chop $str;
