Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision a8b9d61068f3f5cf8e1a42240f2a3128874cc073)
+++ src/builder.cpp	(revision 9a5bcd1b9e1cb7f3d50def75223622b926786d75)
@@ -699,18 +699,21 @@
   mol->CalculateOrbitals(*configuration);
   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
-  if (ConfigFileName != NULL) {
+  strcpy(filename, ConfigFileName);
+  if (ConfigFileName != NULL) { // test the file name
     output.open(ConfigFileName, ios::trunc);
   } else if (strlen(configuration->configname) != 0) {
+    strcpy(filename, configuration->configname);
     output.open(configuration->configname, ios::trunc);
     } else {
+      strcpy(filename, DEFAULTCONFIG);
       output.open(DEFAULTCONFIG, ios::trunc);
     }
+  output.close();
+  output.clear();
   cout << Verbose(0) << "Saving of config file ";
-  if (configuration->Save(&output, periode, mol))
+  if (configuration->Save(filename, periode, mol))
     cout << "successful." << endl;
   else
     cout << "failed." << endl;
-  output.close();
-  output.clear();
   
   // and save to xyz file
@@ -741,21 +744,13 @@
   
   // and save as MPQC configuration
-  if (ConfigFileName != NULL) {
+  if (ConfigFileName != NULL)
     strcpy(filename, ConfigFileName);
-    strcat(filename, ".in");
-    output.open(filename, ios::trunc);
-  }
-  if (output == NULL) {
+  if (output == NULL)
     strcpy(filename,"main_pcp_linux");
-    strcat(filename, ".in");
-    output.open(filename, ios::trunc);
-  } 
   cout << Verbose(0) << "Saving as mpqc input ";
-  if (configuration->SaveMPQC(&output, mol))
+  if (configuration->SaveMPQC(filename, mol))
     cout << "done." << endl;
   else
     cout << "failed." << endl;
-  output.close();
-  output.clear();
   
   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
@@ -919,4 +914,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
               } else {
@@ -934,4 +930,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
               } else {
@@ -995,4 +992,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
               } else {
@@ -1007,4 +1005,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
               } else {
@@ -1023,4 +1022,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
               } else {
@@ -1037,4 +1037,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
               } else {
@@ -1051,4 +1052,5 @@
               ExitFlag = 1;
               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
               } else {
@@ -1077,4 +1079,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl;
               } else {
@@ -1097,4 +1100,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
               } else {
@@ -1132,4 +1136,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
               } else {
@@ -1170,4 +1175,5 @@
               ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
                 volume = -1; // for case 'u': don't print error again
@@ -1180,4 +1186,5 @@
               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
                 if (volume != -1)
+                  ExitFlag = 255;
                   cerr << "Not enough arguments given for suspension: -u <density>" << endl;
               } else {
@@ -1202,4 +1209,5 @@
               ExitFlag = 1;
               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+                ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
               } else {
