make sure the web user has write access to the current directory or write access to the dir you're outputting to.
I have no idea what path > testfile would go to personally and I would never give the web user write permissions on any folder under documentroot.
Check your security and try again.