Binance returns tickers even for the delisted pairs. As a result, the script downloads these pairs continuously.
Adding something like this will help to skip this kind of pairs.
if len(binance.client.Client(None, None).get_klines(symbol=pair, interval='5m', startTime=1610755200000)) > 0: