Zend certified PHP/Magento developer

Looking for some help on how to fix a minor problem. My website has php running in the background to read from a text file. The issue is that sometimes this code doesn’t run unless I refresh the page. It happens intermittently though. Any way to resolve this?