Check lines.hasNext() before this and throw a meaningful exception if it does not.