Added the ability to write the data to a file