added a saving function with a .dat data.