Basic Java Sever loses connection after changing url

I have folder that contains working index.html and about.html. I have created a basic server that lives in this folder as well. When I connect to localhost:9999/index.html everything works fine but, when I enter localhost:9999/about.html I get a connection error. If I enter localhost:9999/about.html first it works fine but then again when I re-enter localhost:9999/index.html I get an error connection.

Below you will find the code and the output error I received from terminal:

import java.io.*;
import java.net.*;
import java.util.Scanner;
public class MyWebServer {
    public static void main(String args[]) {
// declaration section:
// declare a server socket and a client socket for the server
// declare an input and an output stream
        ServerSocket echoServer = null;
        String line;
    BufferedReader in;
    PrintStream os;
        Socket clientSocket = null;
    System.out.println("Initializing Socket");
    boolean end = false;
// Try to open a server socket on port 9999
// Note that we can't choose a port less than 1023 if we are not
// privileged users (root)
        try {
           echoServer = new ServerSocket(9999);
       System.out.println("Listening on Port "+echoServer.getLocalPort());
        }
        catch (IOException e) {
           System.out.println(e);
        }   
// Create a socket object from the ServerSocket to listen and accept 
// connections.
// Open input and output streams
// TO DO: Do this in a loop. Otherwise only one HTTP request will be served.
        while(true)
        {
        try {

            clientSocket = echoServer.accept();
        System.out.println("Connection from "+clientSocket.getInetAddress());
        in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
               os = new PrintStream(clientSocket.getOutputStream());
        String wp = in.readLine();
        System.out.println(wp);
        String htmlCode = getHtmlCode(getPage(wp));
// As long as we receive data, echo that data back to the client.
        os.print("HTTP/1.1 200 OK/n/n"+htmlCode);
        os.close();
        in.close();

         }   
        catch (IOException e) {
               System.out.println(e);
           }
        }
    }

    public static String getPage(String request){
        String[] htmlFile = request.split(" ");

        String x = htmlFile[1].substring(1);


    return x;
    }

    public static String getHtmlCode(String file){

       String content = "";
       try
       {
           content = new Scanner(new File(file)).useDelimiter("//Z").next();
       }
       catch(FileNotFoundException e)
       {
           System.out.println(e);
       }
    return content;
    }
}

Josephs-MacBook-Pro-2:ws_homework Jrod730$ javac MyWebServer.java
Josephs-MacBook-Pro-2:ws_homework Jrod730$ java MyWebServer
Initializing Socket
Listening on Port 9999
Connection from /0:0:0:0:0:0:0:1
GET /about.html HTTP/1.1
Connection from /0:0:0:0:0:0:0:1
GET /css/bootstrap.min.css HTTP/1.1
Connection from /0:0:0:0:0:0:0:1
GET /css/magnific-popup.css HTTP/1.1
Connection from /0:0:0:0:0:0:0:1
GET /css/templatemo-style.css HTTP/1.1
Connection from /0:0:0:0:0:0:0:1
GET /img/tm-neaty-logo.png HTTP/1.1
Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1371)
    at MyWebServer.getHtmlCode(MyWebServer.java:67)
    at MyWebServer.main(MyWebServer.java:40)