Writing objects to file.