Updated process_eof() function with error msg's