Exit if input can't be opened or once we reach the end of it.