title: Spotify puzzle: avoiding exception handling error
body: <p>I'm working on a Spotify puzzle (viewable <a href="http://www.spotify.com/uk/jobs/tech/zipfsong/" rel="nofollow">here</a>). I'm writing the solution in Java and I've gotten my code to pass their two example inputs in Eclipse, on ideone.com, and through Terminal on my osx, all without errors. However whenever I submit to the Spotify bot I get the following minimalist response:</p>
  
  <blockquote>
    <p>We have tested your solution, and while doing so we unfortunately</p>
    
    <p>discovered the following error: Run Time Error</p>
    
    <p>An exception was not caught</p>
  </blockquote>
  
  <p>Here's basically what I do to read in input:</p>
  
  <pre><code>scn = null;
  
  try {
      scn = new Scanner(System.in);
  
        if(scn.hasNext()){
        strIn = scn.nextLine();
        //do work on first line of input
        }
  
        if(scn.hasNext()){
        strIn = scn.nextLine();
        //do work on second line of input
        }
  
        //do work on the rest of the lines
        while (scn.hasNext()) {
        strIn = scn.nextLine();
  
        if(/*reached last line*/){
             break;
        }
        }
  
    }
  
    catch(Exception e){
        System.out.println("Exception caught");
        System.out.println(e.getStackTrace());
  
    } finally {
        if (scn != null) {
            scn.close();
        }
    }
  </code></pre>
  
  <p>You can view my complete solution <a href="http://ideone.com/B96Qcf" rel="nofollow">here</a>. Note that my actual submission declares my class public, as per the Spotify submission guidelines.</p>
  
  <p>Since the problem requires only simple I/O from stdin to stdout, it seems like I only need to account for any exceptions that may be thrown when I'm reading in input within my try block. I provide a catch block for all Exceptions (bad form I know) but shouldn't that handle it? Maybe I'm neglecting some exceptions that could be popping up elsewhere?</p>
  
  <p>It may be that I'm not accounting for some small peculiarity about how the Spotify bots parse input, but their response message and guidelines make it hard to pinpoint where exactly the problem is. I apologize if this question is too localized - other Spotify puzzle questions were seen this way - but I figure my i/o and exceptons questions are broad enough, and perhaps people have some good answers on how the Spotify bots might work. Also, it's been a while since I've coded in Java, so any other comments are certainly welcome.</p>