Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision 19892d8d4b3e7063877efba20bee402e3caa3695)
+++ src/config.cpp	(revision 6b8b57c269257f8192eb7f11ffd114cf48339f05)
@@ -652,4 +652,5 @@
     atom *neues = NULL;
     while (status) {
+      cout << "Currently parsing MD step " << repetition << "." << endl;
       for (int i=0; i < config::MaxTypes; i++) {
         sprintf(name,"Ion_Type%i",i+1);
@@ -1060,4 +1061,55 @@
 };
 
+/** Stores all elements in a MPQC input file.
+ * Note that this format cannot be parsed again.
+ * \param output open output *file stream to write to
+ * \param *mol pointer to molecule containing all atoms of the molecule 
+ */
+bool config::SaveMPQC(ofstream *output, molecule *mol) const
+{
+  int ElementNo;
+  int AtomNo;
+  atom *Walker = NULL;
+  element *runner;
+  Vector center;
+
+  *output << "% Created by MoleCuilder" << endl;
+  *output << "mpqc: (" << endl;
+  *output << "\tsavestate = no" << endl;
+  *output << "\tdo_gradient = yes" << endl;
+  *output << "\tmole<CLHF>: (" << endl;
+  *output << "\t\tmolecule<Molecule>: (" << endl;
+  *output << "\t\t\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
+  *output << "\t\t\t{ atoms geometry } = {" << endl;
+  mol->DetermineCenter(center);
+  // output of atoms
+  ElementNo = 0;
+  runner = mol->elemente->start;
+  while (runner->next != mol->elemente->end) { // go through every element
+    runner = runner->next;
+    if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms
+      ElementNo++;
+      AtomNo = 0;
+      Walker = mol->start;
+      while (Walker->next != mol->end) { // go through every atom of this element
+        Walker = Walker->next;
+        if (Walker->type == runner) { // if this atom fits to element
+          AtomNo++;
+          *output << "\t\t\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center.x[0] << "\t" << Walker->x.x[1]-center.x[1] << "\t" << Walker->x.x[2]-center.x[2] << " ]" << endl;
+        }
+      }
+    }
+  }
+  *output << "\t\t\t}" << endl;
+  *output << "\t\t)" << endl;
+  *output << "\t\tbasis<GaussianBasisSet>: (" << endl;
+  *output << "\t\t\tname = \"STO-3G\"" << endl;
+  *output << "\t\t\tmolecule = $:mpqc:mole:molecule" << endl;
+  *output << "\t\t)" << endl;
+  *output << "\t)" << endl;
+  *output << ")" << endl;
+  return true;
+};
+
 /** Reads parameter from a parsed file.
  * The file is either parsed for a certain keyword or if null is given for
@@ -1103,5 +1155,5 @@
           Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy");
           //Error(InitReading, name);
-          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
+          //fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
           exit(255);
         } else {
@@ -1114,5 +1166,5 @@
       }
       line++;
-    } while (((dummy1[0] == '#') || (dummy1[0] == '\n')) && dummy != NULL); // skip commentary and empty lines
+    } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines
     
     // C++ getline removes newline at end, thus re-add
@@ -1122,9 +1174,10 @@
       dummy1[i+1] = '\0';
     }
-    //fprintf(stderr,"line ends at %i, newline at %i\n", strlen(dummy1), strchr(dummy1,'\n')-free_dummy);
+    //fprintf(stderr,"line %i ends at %i, newline at %i\n", line, strlen(dummy1), strchr(dummy1,'\n')-free_dummy);
+
     if (dummy1 == NULL) {
       if (verbose) fprintf(stderr,"Error reading line %i\n",line);
     } else {
-      //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1);
+      //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1);
     }
     // Seek for possible end of keyword on line if given ...
@@ -1204,8 +1257,4 @@
               if (dummy == NULL)
                 dummy = strchr(dummy1, ' ');  // if not found seek for space
-              while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))    // skip some more tabs and spaces if necessary
-                dummy++;
-/*              while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))    // skip some more tabs and spaces if necessary
-                dummy++;*/
               if (dummy == NULL) { // if still zero returned ...
                 dummy = strchr(dummy1, '\n');  // ... at line end then
