That was my first thought as well. But if it was a permission problem, then neither method would work. unlink() just returns the number of files unlinked, so it returns 1 for the snippet that works and 0 for the snippet that doesn't work, in this case.