Fix "global name 'p' is not defined" in get_pfile