private String doNext(int num, boolean remove) {
		if (pos == input.length()) {
			throw new IllegalStateException("End of stream");
		}		
		prevPos = pos;
		
		String str = null;
		for (int i = 0; i < num; i ++) { //look ahead
			StringBuilder res = new StringBuilder();
			String c;
			res.append(c = read());
			pos ++;
			if (!isSpecial(c)) {
				for (; pos < input.length() - 1 && !isSpecial(c = read()); pos ++) {
					res.append(c);
				}
			}
						
			for (; pos < input.length() - 1 && isSpace(read()); pos ++); //skip spaces
			
			str = res.toString();
		}
		
		if (!remove) {
			pos = prevPos;
		}		
		return str;
	}