title: scanning an array to pick a random string from it
body: <p>I have a text file and I want to randomly pick a string out of there. Have some code, but it doesn't work properly</p>
  
  <pre><code>File file = new File("name.txt");
      Scanner scanner = new Scanner(file);
      Random random = new Random();
      while (scanner.hasNextLine()) {
          String line = scanner.nextLine();
          String[] s = {line};
          int select = random.nextInt(s.length); 
          System.out.println(s[select]);
  </code></pre>
  
  <p>if I do so it prints the whole file without any random method. Have I missed something?</p>