public GrepServer() {
		//System.out.println("Listen: Construct Start");
		for (int i = 1024; i < 1500; i ++) {
			try {
			    sock = new ServerSocket(i);
			} 
			catch (IOException e) {
			    System.err.printf("Could not listen on port: %d, Trying %d\n", i, i+1);
			    continue;
			}
			break;
		}
		
		//System.out.println("Listen: Construct End");
		Properties prop = new Properties();
		String ports = null;
		try {
			hostname = InetAddress.getLocalHost().getHostName();
			localPort = Integer.toString(sock.getLocalPort());
			System.out.println("Running on host: "+ hostname + " port: " + localPort);
		} catch (UnknownHostException e) {
			e.printStackTrace();
			System.exit(-1);
		}
	    try {
	    	try {
	    		prop.load(new FileInputStream("config.properties"));
			} catch (FileNotFoundException e) {
				System.err.println("Cannot load file, exiting");
				e.printStackTrace();
				System.exit(-1);
			}

			ports = prop.getProperty(hostname);
			if (ports  == null) {
				prop.setProperty(hostname, localPort);
			} else if (!ports.contains(localPort)) {
				ports = ports + "," + localPort;
				prop.put(hostname, ports);
			} else {
				System.out.println("Unhandled Case, Ports already in file");
			}
			prop.store(new FileOutputStream("config.properties"), null);		
		} catch (IOException e) {
			e.printStackTrace();
			System.err.println("IOException, exiting");
			System.exit(-1);
		}
	}