Using Java Scanner's hasNext(Pattern) to find a leading '+'
<p>I have a scanner that has been working smoothly up until I try the hasNext(Pattern) method to look for a leading '+' character. Here's what I have been trying to do:</p>

<pre><code>File file = new File("Somefile.txt");
Scanner input = new Scanner(file);
while (!input.hasNext(Pattern.compile("^\\+"))) {
   System.out.println("No leading +:" + input.next());
}
</code></pre>

<p>Which sure seems to make sense. However the program loops endlessly past plenty of lines with leading '+'. What am I doing wrong?</p>
