fix appending to csv file