fixed CSV writing