fix writing of csvs