Python Regex Problem to find emails from a file filled with random garbage and emails.

My assignment is to find emails from a txt file filled with emails, IPs and a lot of other unknown symbols. I extracted emails using regex but there are some emails which do not fulfill the category and are still printed. Please help me with this.

Here’s my code. I don’t know how to attach the text file in this forum.

import re
with open("RegularExpression.txt", "r+", encoding="ANSI") as R:
  Regex = R.read()
  email = re.compile('\w+@[A-Za-z]+\.[A-Za-z0-9]+\.?[A-Za-z]+')
  match1 = email.findall(Regex)
  for match in match1:
      print(match)