public void start(InputStream istream, OutputStream ostream) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(istream));
        PrintWriter writer = new PrintWriter(ostream);
        String line;
        System.out.println("Enter \\quit to finish.");
        try {
            while ((line = reader.readLine()) != null) {
                if (line.equals("\\quit")) {
                    System.out.println("Thank you for using my search application!");
                    return;
                }
                try {
                    List<String> files = index.processQuery(line);
                    if (files.size() == 0) {
                        writer.println("\tno documents found!");
                        writer.flush();
                    } else {
                        writer.print("\tfound: ");
                        for (int i = 0; i < files.size(); ++i) {
                            if (i > 1) {
                                writer.print("and " + (files.size() - i) + " more...");
                                break;
                            }
                            writer.print(files.get(i) + " ");
                        }
                        writer.println();
                        writer.flush();
                    }
                } catch (IncorrectQueryException e) {
                    System.err.println("Incorrect query!");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }