add writing to csv on event occurence