If cfgfn is None then the config dir could not be found either, so there's no sense in trying to create a template file (in fact calling get_config_dir raises an OSError