--- a/src/hugin1/PT/PanoCommand.h
+++ b/src/hugin1/PT/PanoCommand.h
@@ -1217,14 +1217,15 @@
     class LoadPTProjectCmd : public PanoCommand
     {
     public:
-        LoadPTProjectCmd(Panorama & p, std::istream & i, const std::string & prefix = "")
+        LoadPTProjectCmd(Panorama & p, const std::string  & filename, const std::string & prefix = "")
             : PanoCommand(p),
-              in(i),
-	      prefix(prefix)
+            filename(filename),
+            prefix(prefix)
             { }
 
         virtual bool processPanorama(Panorama& pano)
             {
+                std::ifstream in(filename.c_str());
 #ifndef _Hgn1_PANORAMA_H
                 PanoramaMemento newPano;
                 if (newPano.loadPTScript(in,prefix)) {
@@ -1240,6 +1241,7 @@
                 }
 #endif
                 
+                in.close();
                 pano.changeFinished();
 
                 return true;
@@ -1251,7 +1253,7 @@
             }
 
     private:
-        std::istream & in;
+        const std::string &filename;
         const std::string &prefix;
     };