I think file_exists() has some problems in safe mode?   is_file() will probably do the trick though.