Added an enclosure for the csv writer
Handle end of product