writing data to csv file