writing data to file every time a date is finished