Fixes writecsv syntax error

- Variable error within writecsv has been corrected. Now correctly
refers to the number of columns in the input variable.