write data to csv as well