diff --git a/src/tools/FileBase.cpp b/src/tools/FileBase.cpp
index b9eb0277d176c8fb38bd986a692f2dc0f63190a1..69ce12144e8dbdfdb69f37f9d77da885fd7f0de0 100644
--- a/src/tools/FileBase.cpp
+++ b/src/tools/FileBase.cpp
@@ -103,10 +103,12 @@ bool FileBase::FileExist(const std::string& path){
   if(plumed){
     this->path=appendSuffix(path,plumed->getSuffix());
     ff=std::fopen(const_cast<char*>(this->path.c_str()),"r");
+    mode="r";
   }
   if(!ff){
     this->path=path;
     ff=std::fopen(const_cast<char*>(this->path.c_str()),"r");
+    mode="r";
   }
   if(ff) {do_exist=true; fclose(ff);}
   if(comm) comm->Barrier();
diff --git a/src/tools/FileBase.h b/src/tools/FileBase.h
index 4c2b71d7285762db807c0b4549a166444a5e7d2b..66b8354eec160fda08af0adb6a937a671291b6bb 100644
--- a/src/tools/FileBase.h
+++ b/src/tools/FileBase.h
@@ -75,6 +75,8 @@ protected:
   bool err;
 /// path of the opened file
   std::string path;
+/// mode of the opened file
+  std::string mode;
 /// Set to true if you want flush to be heavy (close/reopen)
   bool heavyFlush;
 /// Append suffix.
@@ -111,8 +113,23 @@ public:
   bool FileExist(const std::string& path);
 /// Check if a file is open
   bool isOpen();
+/// Retrieve the path
+  std::string getPath()const;
+/// Retrieve the mode
+  std::string getMode()const;
 };
 
+inline
+std::string FileBase::getPath()const{
+  return path;
+}
+
+inline
+std::string FileBase::getMode()const{
+  return mode;
+}
+
+
 
 }
 
diff --git a/src/tools/OFile.cpp b/src/tools/OFile.cpp
index 25312b5d1325a4de95cb75829dd2f84c8fdd648c..7dbf0184d4ebed6983617fae4de4f30720f1c5be 100644
--- a/src/tools/OFile.cpp
+++ b/src/tools/OFile.cpp
@@ -287,6 +287,7 @@ OFile& OFile::open(const std::string&path){
   }
   if(checkRestart()){
      fp=std::fopen(const_cast<char*>(this->path.c_str()),"a");
+     mode="a";
      if(Tools::extension(this->path)=="gz"){
 #ifdef __PLUMED_HAS_ZLIB
        gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"a9");
@@ -298,6 +299,7 @@ OFile& OFile::open(const std::string&path){
      backupFile( backstring, this->path );
      if(comm)comm->Barrier();
      fp=std::fopen(const_cast<char*>(this->path.c_str()),"w");
+     mode="w";
      if(Tools::extension(this->path)=="gz"){
 #ifdef __PLUMED_HAS_ZLIB
        gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"w9");