private void file_search(String nickname, String query) throws IOException {

		/* (Re)build list of files in directory */
		File directory = new File(folder);
		if (!directory.isDirectory()) {
			gui.update("[Client] ERROR: Not a directory.");
			return;
		}

		if (directory.listFiles().length == 0 || !open) {
			return;
		}

		/* Search for file(s) matching query */
		LinkedList<String> results = new LinkedList<String>();
		File[] files = directory.listFiles();
		for (int i = 0; i < files.length; i++) {
			if (files[i].toString().replaceAll(folder + "/", "").toLowerCase()
					.contains(query.toLowerCase())) {
				if (files[i].toString()
						.charAt(files[i].toString().length() - 1) != '~' && files[i].isFile())
					results.add(files[i].toString()
							.replaceAll(folder + "/", ""));
			}
		}
		if (results.isEmpty()) return;

		/* Tell server to expect file list */
		outToServer.writeInt(8);
		/* Tell server who the file list is for */
		outToServer.writeUTF(nickname);
		/* Tell server how long the list is. */
		outToServer.writeInt(results.size());
		/* Send results */
		for (String s : results) {
			outToServer.writeUTF(s);
		}
	}