Searching for an exact value in files before sending it to a function

How do I correct the spelling of the user prompt, e.g. of a port, by referring to a file where I have all the names listed and take that exact value before sending it to a function?