convert list to string and write to file