Alternative approach to use isFileEnd