Validate and write yaml file