I'm trying to output some results (title, url) from Google Custom Search in Java command line for testing, but I keep getting a java.io.EOFException error. The compiler lists out the offending line, but I can't figure out what to change, even after spending hours searching for an answer. I took most of the code from an existing question here on Stack Overflow. Any help is appreciated.

```
package google.api.search;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import com.google.gson.Gson;

class GSearch {

public static void main(String args[]) throws IOException  {
   String key = ""; //replace with API key
   String qry = ""; // search key word
   String cx = ""; //replace with cx
   URL url = new URL ("https://www.googleapis.com/customsearch/v1?key=" +key+ "&cx=" +cx+ "&q=" +qry+ "&alt=json");

   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
   conn.setRequestMethod("GET");
   conn.setRequestProperty("Accept","application/json");
   BufferedReader br = new BufferedReader(new InputStreamReader ( ( conn.getInputStream() ) ) );

   String output;
   {while ((output = br.readLine()) != null){
       GResults results = new Gson().fromJson(output, GResults.class);
       System.out.println(results);
   }   
   conn.disconnect(); 
   }  
   }
}

```

GResults class:

```
public class GResults {

String title;
String link;

public GResults(String title, String link) {
    this.title = title;
    this.link = link;
}

public String getTitle(){
    return title;
}

public String getLink(){
    return link;
}

public void setTitle(String title){
    this.title = title;
}

public void setLink(String link){
    this.link = link;
}

public String toString(){
    return ("Title:%s, Link:%s", title, link);
}   
}

```

Error line:

```
GResults results = new Gson().fromJson(output, GResults.class);

```

Error messages:

```
Exception in thread "main" com.google.gson.JsonSyntaxException: java.io.EOFException: End of input at line 1 column 2
at com.google.gson.Gson.fromJson(Gson.java:813)
at com.google.gson.Gson.fromJson(Gson.java:768)
at com.google.gson.Gson.fromJson(Gson.java:717)
at com.google.gson.Gson.fromJson(Gson.java:689)
at google.api.search.GSearch.main(GSearch.java:26)
Caused by: java.io.EOFException: End of input at line 1 column 2
at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1377)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:483)
at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:403)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.Gson.fromJson(Gson.java:803)
... 4 more

```