Added some functionality to save the data to a file.