Make csv in output file working