I'm having trouble pinpointing the exact problem in my code. I have two functions- `inrange()`, which checks to see if a port is in range, and `filt()`, which takes a txt file, looks for the keywords "UDP" or "TCP", looks at the port (right after the : mark), and checks to see if that number is within the range or not. 

```
def inrange(file,character, num): 
    with open(file, 'r') as r:
        for lines in r:
            for key, value in sshd.items():
                if character == key and character in lines:
                    if num in sshd.get(character):
                        return True
                    else:
                        return False

                elif character == key and character in lines:
                    if num in sshd.get(character):
                        return True
                    else:
                        return False

```

This is specifically for sshd for now. 

```
def filt(file):
    with open(file, 'r') as r:
        for i, line in enumerate(r):
            if "sshd"  in line:
                plusOne = i + 1
                newline = line.strip()
                splitIt = newline[7:22]
                my_string = splitIt.split(":", 1)[1]
                if inrange(file, "TCP", int(my_string)):
                    print("Line " + str(plusOne) + " is in range" + " " + my_string)    
                elif inrange(file, "UDP", int(my_string)):
                    print("Line " + str(plusOne) + " is in range" + " " + my_string)     
                else:
                    print("Not in range")

```

Now this works if I have this as my text file- 

Active Connections

```
  Proto  Local Address          Foreign Address        State           PID
  UDP    0.0.0.0:123             0.0.0.0:0             LISTENING       5987  sshd

```

as you can see, UDP 123 is within range if you look at the dictionary `sshd` above. I get a true statement in return. If I change UDP to TCP, it gives me back a negative statement. That works. The problem happens when I add more than one line to this. 

```
Active Connections

  Proto  Local Address          Foreign Address        State           PID
  UDP    0.0.0.0:123             0.0.0.0:0             LISTENING       5987  sshd
  TCP    0.0.0.0:123             0.0.0.0:0             LISTENING       5987  sshd
  UDP    0.0.0.0:123             0.0.0.0:0             LISTENING       5987  sshd
  TCP    0.0.0.0:123             0.0.0.0:0             LISTENING       5987   sshd

```

I get back all positive results:

```
Line 5 is in range 123    
Line 6 is in range 123    
Line 7 is in range 123    
Line 8 is in range 123 

```

which shouldn't be the case, as line 6 and line 8 are TCPs in port 123, which is not in range. I feel like I'm missing something clear here. Cant figure it out.