change writeListToFile to csv format