updated cities algorithm to write to text file

instead of list