import time file = open('input.txt', 'r') text = file.readlines() file.close() address = input("Pull private key for: ") for line in text: # Replacement for re.compile if address in line: output = line; file = open('output.txt', 'r+') file.write(output) file.close() print (output) print ("The private key has been written to output.txt.") time.sleep(5)