Added write_mat to save matrix as .csv in /data