title: BufferedWriter not writing to file
body: <p>I am making a program, and I need to add a list of random 6-digit ids to a file. Currently whenever I run this portion of the program, nothing is added to the file. What exactly am I doing wrong so that the code does not write to the file? I checked and made sure that all the random number are definitely being generated.</p>
  
  <pre><code>static HashSet&lt;Integer&gt; idHashList = 
          new HashSet&lt;&gt;();
  
  public static void createIds(){
      File writeId = new File("peopleIDs.txt");
      try {
          FileWriter fw = new FileWriter(writeId,true);
          BufferedWriter out = new BufferedWriter(fw);
  
          for(int i = 0; i &lt; 100; i++){
              out.write(People.genRand());
          }
          out.close();
      } catch (IOException ex) {
          System.out.println(ex.getMessage());
      }
  }
  
  protected static int genRand(){
      while(true){
          int rand = ((int) ((Math.random() * (899999))+100000));
          if(idHashList.add(rand)){
              return rand;
          }
      }
  }
  </code></pre>