Made Data serializable and updated read and write to file functions