implemented write csv file