import re


def nmap_handle_special(tmp_file):
    """
    This function returns the open ports from nmap scan output file
    :param tmp_file: the file to grep open ports from
    :return: a list of open ports
    """
    for line in open(tmp_file):
        if "Ports" in line:
            line = line.split("Ports")[1].strip(" ").split(",")
            ports = [port.split("/")[0] for port in line]
            ports = [re.sub("[^a-zA-Z0-9 \n\.]", "", port) for port in ports]
            return ports