Index: /trunk/BNC/src/bnccaster.cpp
===================================================================
--- /trunk/BNC/src/bnccaster.cpp	(revision 5527)
+++ /trunk/BNC/src/bnccaster.cpp	(revision 5528)
@@ -60,5 +60,5 @@
 // Constructor
 ////////////////////////////////////////////////////////////////////////////
-bncCaster::bncCaster(const QString& outFileName, int port) {
+bncCaster::bncCaster() {
 
   bncSettings settings;
@@ -67,23 +67,9 @@
           BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
 
-  if ( !outFileName.isEmpty() ) {
-    QString lName = outFileName;
-    expandEnvVar(lName);
-    _outFile = new QFile(lName); 
-    if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
-      _outFile->open(QIODevice::WriteOnly | QIODevice::Append);
-    }
-    else {
-      _outFile->open(QIODevice::WriteOnly);
-    }
-    _out = new QTextStream(_outFile);
-    _out->setRealNumberNotation(QTextStream::FixedNotation);
-  }
-  else {
-    _outFile = 0;
-    _out     = 0;
-  }
-
-  _port = port;
+  _outFile = 0;
+  _out     = 0;
+  reopenOutFile();
+
+  _port = settings.value("outPort").toInt();
 
   if (_port != 0) {
@@ -178,4 +164,6 @@
 
   QMutexLocker locker(&_mutex);
+
+  reopenOutFile();
 
   unsigned index = 0;
@@ -561,2 +549,32 @@
   }
 }
+
+// 
+////////////////////////////////////////////////////////////////////////////
+void bncCaster::reopenOutFile() {
+
+  bncSettings settings;
+
+  QString outFileName = settings.value("outFile").toString();
+  if ( !outFileName.isEmpty() ) {
+    expandEnvVar(outFileName);
+    if (!_outFile || _outFile->fileName() != outFileName) {
+      delete _out;
+      delete _outFile;
+      _outFile = new QFile(outFileName); 
+      if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
+        _outFile->open(QIODevice::WriteOnly | QIODevice::Append);
+      }
+      else {
+        _outFile->open(QIODevice::WriteOnly);
+      }
+      _out = new QTextStream(_outFile);
+      _out->setRealNumberNotation(QTextStream::FixedNotation);
+    }
+  }
+  else {
+    delete _out;     _out     = 0;
+    delete _outFile; _outFile = 0;
+  }
+}
+
Index: /trunk/BNC/src/bnccaster.h
===================================================================
--- /trunk/BNC/src/bnccaster.h	(revision 5527)
+++ /trunk/BNC/src/bnccaster.h	(revision 5528)
@@ -41,5 +41,5 @@
 
  public:
-   bncCaster(const QString& outFileName, int port);
+   bncCaster();
    ~bncCaster();
    void addGetThread(bncGetThread* getThread, bool noNewThread = false);
@@ -66,4 +66,5 @@
    void dumpEpochs(long minTime, long maxTime);
    static int myWrite(QTcpSocket* sock, const char* buf, int bufLen);
+   void reopenOutFile();
 
    QFile*                   _outFile;
Index: /trunk/BNC/src/bncmain.cpp
===================================================================
--- /trunk/BNC/src/bncmain.cpp	(revision 5527)
+++ /trunk/BNC/src/bncmain.cpp	(revision 5528)
@@ -193,6 +193,5 @@
     bncEphUploadCaster* casterEph = new bncEphUploadCaster(); (void) casterEph;
     
-    bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
-                                      settings.value("outPort").toInt());
+    bncCaster* caster = new bncCaster();
     
     BNC_CORE->setCaster(caster);
Index: /trunk/BNC/src/bncwindow.cpp
===================================================================
--- /trunk/BNC/src/bncwindow.cpp	(revision 5527)
+++ /trunk/BNC/src/bncwindow.cpp	(revision 5528)
@@ -2055,6 +2055,5 @@
   enableStartStop();
 
-  _caster = new bncCaster(_outFileLineEdit->text(), 
-                          _outPortLineEdit->text().toInt());
+  _caster = new bncCaster();
 
   BNC_CORE->setPort(_outEphPortLineEdit->text().toInt());
