title: My bufferedWriter is writing random characters even though my getMethod works correctly
body: <p>I am reading in grades and writing their averaged but it keeps writing random characters.
  This is what is being read in and saved:</p>
  <pre><code>            String line = in.nextLine();
              String fields[] = line.split(&quot;,&quot;);
              
              String fname = fields[0];
              String lname = fields[1];
              String id = fields[2];
              Student student = new Student(fname, lname, id);
              
              for(int i = 3; i &lt; fields.length; i++) {
                  student.addGrade(Integer.parseInt(fields[i]));
                  
                  }
              students.add(student);
              
          }
          in.close();
  </code></pre>
  <p>and this is the method:</p>
  <pre><code>  public int getAverage() {
      if(grades.size() == 0) {
          return 0;
      }
      int average = 0;
      int sum=0;
      for (int i=0; i &lt; grades.size();i++){
          
          sum += grades.get(i);               
      }
      
      return  sum/grades.size();      
  }
  </code></pre>
  <p>I don't know where I went wrong because when I do not use the bufferedWriter and I just print them, it is correct.</p>
  <pre><code>        for(Student student : students) {
              out.write(student.getID());
              out.write(&quot;,&quot;);
              out.write(student.getAverage());
              out.write(&quot;,&quot;);
              out.write(student.getLetterGrade());
              out.newLine();
          }
          out.close();
  </code></pre>