Corrected the way CSV is generated