Implementing EOF detection.