Memory File I/O bug fix: The EOF flag was being set one INPUT statement too soon when inputting from a file loaded into user memory (either by referencing the MEM: device or by using the OPTIONS=AUTO_MEMOPEN). That is, it was being set after returning the last line of the file, instead of waiting for the next attempt to read when there was no more data.
Note that the EOF flag really means that we hit EOF before completing the operation. It does not mean that no data was returned. If the last line of a file does not end with a terminator (CRLF or LF), then the EOF flag will be set at the end of returning the last line, even though valid data was input. So to be really sure you are processing all the data in a file, do not assume that EOF means that no data was input. For example:
do
input line #ch, pline
if eof(ch)=1 exit
<process pline>
loop
The above loop is typical but fails to process the last line of the file if that line was not terminated with a CRLF or LF.
do while eof(ch) = 0
input line #ch, pline
<process pline>
loop
The above loop solves that problem, but will process a null line at the end of the file if the last line was properly terminated. To avoid that, you need an additional test...
do
input line #ch, pline
if eof(ch)=0 or pline#"" then
<process pline>
else
exit
endif
loop
The above loop handles both cases properly, processing each line if either EOF has not yet been reached, or if data was input (even if the EOF was reached).