updated write to csv to include num of elements