@Override
        public String next()
        {
            try {

                if ( maxLines > 0 && maxLines <= linesRead ) {
                    throw new NoSuchElementException();
                }
                String result = nextline;
                if ( nextline != null ) {
                    nextline = reader.readLine();
                    if ( nextline == null ) {
                        reader.close();
                    }
                }
                linesRead++;
                return result;
            } catch ( IOException ex ) {
                throw new IllegalArgumentException( ex );
            }
        }