added function to write all names to a new file