Check for EOF in peek()

This checks for EOF in `peek()` to ensure that `peek()` never fails.