Added csv output to script and R wrapper.