#vulnerable code 
                              public void onRunEnd() {
    try {
      final long duration = (System.currentTimeMillis() - this.startTime) / 1000;

      final StringTemplateGroup group = new StringTemplateGroup("mutation_test");
      final StringTemplate st = group
      .getInstanceOf("templates/mutation/mutation_index");
      final BufferedWriter bw = new BufferedWriter(new FileWriter(
          this.reportDir.getAbsolutePath() + File.separatorChar + "index.html"));
      st.setAttribute("summaryList", this.summaryData);
      st.setAttribute("errors", this.errors);
      st.setAttribute("numberOfMutations",
          this.mutatorScores.getTotalMutations());
      st.setAttribute("numberOfDetectedMutations",
          this.mutatorScores.getTotalDetectedMutations());
      st.setAttribute("duration", duration);
      st.setAttribute("mutatorScores", this.mutatorScores);
      bw.write(st.toString());
      bw.close();

    } catch (final IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

  } 
                            #location 21 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              public void onRunEnd() {
    try {
      final long duration = (System.currentTimeMillis() - this.startTime) / 1000;

      final StringTemplateGroup group = new StringTemplateGroup("mutation_test");
      final StringTemplate st = group
          .getInstanceOf("templates/mutation/mutation_index");

      final Writer writer = this.outputStrategy
          .createWriterForFile("index.html");

      st.setAttribute("summaryList", this.summaryData);
      st.setAttribute("errors", this.errors);
      st.setAttribute("numberOfMutations",
          this.mutatorScores.getTotalMutations());
      st.setAttribute("numberOfDetectedMutations",
          this.mutatorScores.getTotalDetectedMutations());
      st.setAttribute("duration", duration);
      st.setAttribute("mutatorScores", this.mutatorScores);
      writer.write(st.toString());
      writer.close();

    } catch (final IOException e) {
      e.printStackTrace();
    }

  }