import sys #inFile = sys.stdin beginSig = "-----BEGIN PGP" endSig = "-----END PGP" output = "" keyBegun = False for line in sys.stdin: sigIndex = 0 if beginSig in line: if keyBegun: exit(1) keyBegun = True sigIndex = line.find(beginSig) if keyBegun: output += line[sigIndex:] if endSig in line: break print(output)