Fix for #485 in write_csv