For consideration, when you uncomment the first INPUT statement, that causes SAS to load the input data buffer and it will trigger the end=LASTREC before the other INPUT statement, so your IF test will pass and the DATA step will stop prematurely.
And, the NOTE (not really an ERROR) that you receive is because you are attempting to read a character field from the 2nd (last) record as numeric, and it is alphabetic, causing the SAS diagnostic message.
In the future, it is best to share your SAS log, please, not just to say that an error occurs. For assistance with a post, send a reply with the log pasted in your submission (instream). Also, consider adding a PUTLOG _ALL_; command before the RUN; to provide as much diagnostics output as possible -- it also may help you debug the problem, as well.
Scott Barry
SBBWorks, Inc.