file in os.listdir replaced with os.path.exists