Fixed bug where filename was .dat.dat and not iterating. Still have problems if script terminate and is started again.