EOF detection