Implemented writing csv file. Refs #9212.