Maybe the conditional isn't working as you think it is. Try outputting debug statements to the HTTP stream and see the code path that is actually being followed.
See my previous post:
I tested this code multiple times with only one PDF document, so I can verify the code on both pages is being executed. Both pages are attempting to load the exact same PDF document. Page1 succeeds and Page2 fails. The PDF I am using
I know for a fact the conditional code is working because I put debug breaks in the proper locations on both files.