Hi guys!

Need some help navigating the confusing sea of network I/O. Ive made a single connection object to a server and need to do multiple queries on that connection using its input- and outputstream. The problem is that the server only returns a result for the first query. Either this is the server (which I doubt), or there us something wrong with my code that makes it not catch the result.

I/O has never been my strong point, but Im guessing the problem is just a misformulation or something somewhere in the code. Anyway, Id be really thankful for any help or just general info about network I/O if there is some major stuff that Ive clearly not understood.

Thanks in advance.

Code:
//running this code multiple times causes the result to be empty on all queries except the first.

	public void doQuery() {
		String res = "";
		String query = word + "#" + pos + "#" + num;
		query.trim();
		try {
			OutputStream out = connection.getOutputStream();
			PrintWriter outw = new PrintWriter(out, false);
			outw.print("GET " + query + " HTTP/1.0\r\n");
			outw.print("Accept: text/plain, text/html, text/*\r\n");
			outw.print("\r\n");
			outw.flush();

			InputStream in = connection.getInputStream();
			InputStreamReader inr = new InputStreamReader(in);
			BufferedReader br = new BufferedReader(inr);
			String line = "";


			while ((line = br.readLine()) != null) {
				res += line;
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		results = res;
	}