Close dat file before copying it upstream and flush the upstream file before releaseing the lock.
Merge pull request #2024 from mommsen/fixCorruptionOfDatFiles

DAQ fixes -- Fix corruption of dat files
Merge remote branch 'origin/CMSSW_7_0_X' into CMSSW_7_0_X