diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index 237b79f10c4ac4a90fc9d1bbef575a7d70aa480c..aac2c6c9d4196838256582e143960de81610a603 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -380,37 +380,45 @@ void PlumedMain::readInputFile(std::string str){
   ifile.open(str);
   std::vector<std::string> words;
   exchangePatterns.setFlag(exchangePatterns.NONE);
-  while(Tools::getParsedLine(ifile,words)){
-    if(words.empty())continue;
-    else if(words[0]=="ENDPLUMED") break;
-    else if(words[0]=="_SET_SUFFIX"){
-      plumed_assert(words.size()==2);
-      setSuffix(words[1]);
-    }
-    else if(words[0]=="RANDOM_EXCHANGES"){
-      exchangePatterns.setFlag(exchangePatterns.RANDOM);
-      // I convert the seed to -seed because I think it is more general to use a positive seed in input
-      if(words.size()>2&&words[1]=="SEED") {int seed; Tools::convert(words[2],seed); exchangePatterns.setSeed(-seed); }
-    } else {
-      Tools::interpretLabel(words);
-      Action* action=actionRegister().create(ActionOptions(*this,words));
-      if(!action){
-        log<<"ERROR\n";
-        log<<"I cannot understand line:";
-        for(unsigned i=0;i<words.size();++i) log<<" "<<words[i];
-        log<<"\n";
-        exit(1);
-      };
-      action->checkRead();
-      actionSet.push_back(action);
-    };
-  };
+  while(Tools::getParsedLine(ifile,words)) readInputWords(words);
   log.printf("END FILE: %s\n",str.c_str());
   log.flush();	
 
   pilots=actionSet.select<ActionPilot*>();
 }
 
+void PlumedMain::readInputWords(const std::vector<std::string> & words){
+  plumed_assert(initialized);
+  if(words.empty())return;
+  else if(words[0]=="ENDPLUMED") return;
+  else if(words[0]=="_SET_SUFFIX"){
+    plumed_assert(words.size()==2);
+    setSuffix(words[1]);
+  }
+  else if(words[0]=="RANDOM_EXCHANGES"){
+    exchangePatterns.setFlag(exchangePatterns.RANDOM);
+    // I convert the seed to -seed because I think it is more general to use a positive seed in input
+    if(words.size()>2&&words[1]=="SEED") {int seed; Tools::convert(words[2],seed); exchangePatterns.setSeed(-seed); }
+  } else {
+    std::vector<std::string> interpreted(words);
+    Tools::interpretLabel(interpreted);
+    Action* action=actionRegister().create(ActionOptions(*this,interpreted));
+    if(!action){
+      log<<"ERROR\n";
+      log<<"I cannot understand line:";
+      for(unsigned i=0;i<interpreted.size();++i) log<<" "<<interpreted[i];
+      log<<"\n";
+      exit(1);
+    };
+    action->checkRead();
+    actionSet.push_back(action);
+  };
+
+  pilots=actionSet.select<ActionPilot*>();
+}
+
+
+
 ////////////////////////////////////////////////////////////////////////
 
 void PlumedMain::exit(int c){
diff --git a/src/core/PlumedMain.h b/src/core/PlumedMain.h
index b95bffcb7bfa3fc7de393a009cad9227c7edf426..c9ef949dc0afc610304d575ce4a7abd8098a1d41 100644
--- a/src/core/PlumedMain.h
+++ b/src/core/PlumedMain.h
@@ -160,6 +160,12 @@ public:
   \param str name of the file
 */
   void readInputFile(std::string str);
+/**
+  Read an input string.
+  \param str name of the string
+*/
+  void readInputWords(const std::vector<std::string> &  str);
+
 /**
   Initialize the object.
   Should be called once.