Use persists() to write hosts collection to a file.