The only problem I can see, is trailing whitespace from the ip.txt file. Perhaps ClientIP.strip() will help?