changed 0th order to output comma-delimited and to write instead of append