added capability to write data to a file