Replace open(...) with range(...)