CSV output helper function