CSV output now uses csv and StringIO instead of being hand-assembled.