Updated to support writing to temp.dat