diff --git a/paramiko/pkey.py b/paramiko/pkey.py index 1b4af010f..7d2be468c 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -273,7 +273,7 @@ def _read_private_key(self, tag, f, password=None): start += 1 # find end end = start - while (lines[end].strip() != '-----END ' + tag + ' PRIVATE KEY-----') and (end < len(lines)): + while end < len(lines) and lines[end].strip() != '-----END ' + tag + ' PRIVATE KEY-----': end += 1 # if we trudged to the end of the file, just try to cope. try: