add funcion 'writing to csv file'