Actually, with only your first line modified for an accurate "path" to the file, you code works fine for me.
You can see it working in two versions:
http://maddogz.com/dev/lock.php shows your test code working with line 2 as:
$fp = fopen("lock.txt", "w+");
http://maddogz.com/dev/lock2.php shows your test code working with line 2 as:
$fp = fopen("path/lock.txt", "w+");
This makes me think that the problem is not with PHP, or probably even with the code, but likely a permissions, or an .htaccess issue.
Have you checked to make sure there have been no changes in your system in those areas. (like an .htaccess file added/modified, or permission reset/changed on any of the involved files/directories)?