Updated algorithms used to write and read data files to be more memory efficient