fix bug for EOF