private void runCrawler() {
		PrintStream outStream = new PrintStream(outFile);
		/* The safe state is after completely checking a single url */
		while (linksToCheck.isEmpty() == false && suspending == false) {
			URL curURL = linksToCheck.dequeue();
			// Don't check this url if it's already been seen.
			if (seenLinks.containsKey(curURL)) continue;
			else seenLinks.put(curURL, true);
			outStream.println("LINKS FROM " + curURL);
			BufferedReader incomingHTML;
			try {
				incomingHTML = new BufferedReader(new InputStreamReader(curURL.openStream()));
		        String curLine;
		        curLine = incomingHTML.readLine();
		        //Process the HTML for a single url line by line
				while (curLine != null) {
					//Check for the <a> tag 
					Pattern linkPattern = Pattern.compile("(?i)<a([^>]+)>(.+?)</a>");
					Pattern urlFromLinkPattern = Pattern.compile("\\s*(?i)href\\s*=\\s*\"([^\"]*\"|'[^']*'|[^'\">\\s]+)");
					Matcher matchOnLink = linkPattern.matcher(curLine);
					while (matchOnLink.find()){
						String href = matchOnLink.group(1);
						Matcher hrefPart = urlFromLinkPattern.matcher(href);
						//Now check for the href attribute in the tag
						while (hrefPart.find()) {
							String newLink = hrefPart.group(1);
							//Remove the "" at the end of the url
							newLink = newLink.replace("\"", "");
							try {
								linksToCheck.enqueue(new URL(newLink));
								outStream.println("       OUTGOING LINK: " + newLink);
							}
							catch (MalformedURLException e) {
							}
						}
					}
					//Update the current line
				    curLine = incomingHTML.readLine();
				}
		        incomingHTML.close();
			} catch (IOException e) {
				outStream.println("ERROR: Bad URL on queue.");
			}
		}
		suspending = false;
	}