If the tmp_ip file is being written to correctly, then you may have a problem with your IP changing as you access the script. If you're connecting by way of a proxy or something like that, that may be the source of the problem.