I am trying to write in a tabular form in .csv file. many string variables (freq  voltage  current  S11    S22    S21    S12) contains big data.
for exp, 

... and so on ...
first I converted all variables data row into column by replacing "," to "\n", for writing in vertical form. for exp,
 convert to
convert to 

string voltage , freq, curt;
freq= tmp.query("*FMA?\n");
voltage = tmp.query("*VOL?\n");
curt=   tmp.query("*CURR?\n");
replace(begin(freq), end(freq), ',', '\n');
replace(begin(voltage ), end(voltage), ',', '\n');
replace(begin(curt), end(curt), ',', '\n');
filewrite << freq<< voltage <<curt; 


 
    