writing objects to files