output: #fixed code
                                  public void setPlatform(String platform) throws FileNotFoundException, IOException {
          if(!platformPattern.matcher(platform).matches())
              throw new IllegalArgumentException("Platform must match " + platformPattern.pattern());
  
          this.platform = platform;
          rewriteHeader();
      }
input: #vulnerable code 
                                  public void setPlatform(String platform) throws FileNotFoundException, IOException {
          if(!platformPattern.matcher(platform).matches())
              throw new IllegalArgumentException("Platform must match " + platformPattern.pattern());
  
          File tempFile = new File(file.getAbsolutePath() + ".tmp");
          BufferedReader br;
          PrintWriter pw;
  
          if(compressed) {
              GZIPInputStream zipStream = new GZIPInputStream(new FileInputStream(file));
              br = new BufferedReader(new InputStreamReader(zipStream));
              GZIPOutputStream outStream = new GZIPOutputStream(new FileOutputStream(tempFile));
              pw = new PrintWriter(outStream);
          } else {
              br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
              pw = new PrintWriter(new FileWriter(tempFile));
          }
  
          String line = null;
          boolean written = false;
  
          while ((line = br.readLine()) != null) {
              /* If line is found overwrite it */
              if (!written && line.startsWith(("PLATFORM"))) {
                  pw.println("PLATFORM " + platform);
                  written = true;
              /* If header has no such field add it */
              } else if(!written && line.startsWith("(")) {
                  pw.println("PLATFORM " + platform);
                  pw.println(line);
                  written = true;
              /* Write all other header lines */
              } else {
                  pw.println(line);
                  pw.flush();
              }
          }
  
          pw.close();
          br.close();
  
          if (!file.delete()) {
              logger.log(Level.WARNING, "Could not delete old file");
              return;
          }
  
          if (!tempFile.renameTo(file)) {
              logger.log(Level.WARNING, "Could not rename new file to old filename");
          }
  
          this.platform = platform;
      } 
                              #location 10 
                              #vulnerability type RESOURCE_LEAK