dbtoyaml: fix RuntimeError when using -n option

RuntimeError: dictionary changed size during iteration