Sounds like you should check whether `cfile is None` before `.append()`ing it to `config_file` so that here you can instead check `if config_file:` and you will also not have a bug in the next loop where you don't check for `None` entries in `config_file`.