I see a couple of things:
1) You are opening the file in the same directory as the script is in, this means that php has write access to a directory that is accessible via a browser. Therefor, a novice hacker could destroy your site by writting their own php file to this directory then browsing to it.
2) While not truely necessary you should check if the file exists before you open it and if it does not exist create it and chmod it 777. That way you can modify the file through ftp instead of needing a php interface to modify it.
3) You lock the file after you've already written to it, which makes no sense. The only reason to lock a file is so that two writes don't happen at once.