fixed csv writing