Program: 133739
Project: 133739
Buggy source:
/** 
 * This method is intended to take a filePath corresponding to a MOOSE YAML or action syntax file, and remove any extraneous header or footer lines that aren't valid syntax. If any lines from the file were removed, it re-writes the file. If no changes were made (no header/footer to remove), it does nothing.
 * @param filePath	The filepath to the YAML or action syntax file.
 * @throws IOException
 * @throws CoreException 
 */
private void createCleanMOOSEFile(String filePath) throws IOException, CoreException {
  String fileExt, execName, fileType=null;
  boolean hasHeader=false, hasFooter=false;
  int headerLine=0, footerLine=0;
  String separator=System.getProperty("String_Node_Str");
  ArrayList<String> fileLines;
  IFolder mooseFolder=project.getFolder("String_Node_Str");
  if (!mooseFolder.exists()) {
    mooseFolder.create(true,true,null);
  }
  fileExt=filePath.substring(filePath.lastIndexOf("String_Node_Str"));
  execName=filePath.substring(filePath.lastIndexOf(separator) + 1,filePath.lastIndexOf(fileExt));
  String cleanFilePath=filePath.substring(0,filePath.lastIndexOf(separator)) + separator + "String_Node_Str"+ separator+ execName+ fileExt;
  if ("String_Node_Str".equals(fileExt)) {
    fileType="String_Node_Str";
  }
 else   if ("String_Node_Str".equals(fileExt)) {
    fileType="String_Node_Str";
  }
 else {
    System.out.println("String_Node_Str" + "String_Node_Str" + fileExt);
  }
  java.nio.file.Path readPath=Paths.get(filePath);
  fileLines=(ArrayList<String>)Files.readAllLines(readPath,Charset.defaultCharset());
  String header="String_Node_Str" + fileType + "String_Node_Str";
  String footer="String_Node_Str" + fileType + "String_Node_Str";
  hasHeader=fileLines.contains(header);
  hasFooter=fileLines.contains(footer);
  if (hasFooter) {
    footerLine=fileLines.indexOf(footer);
    int i=footerLine;
    while (i < fileLines.size()) {
      fileLines.remove(i);
    }
  }
  if (hasHeader) {
    headerLine=fileLines.indexOf(header);
    for (int i=headerLine; i >= 0; i--) {
      fileLines.remove(i);
    }
  }
  if (hasHeader || hasFooter) {
    java.nio.file.Path writePath=Paths.get(cleanFilePath);
    Files.write(writePath,fileLines,Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.APPEND);
    File oldFile=new File(filePath);
    oldFile.delete();
  }
  return;
}

Fixed version (ground truth):
/** 
 * This method is intended to take a filePath corresponding to a MOOSE YAML or action syntax file, and remove any extraneous header or footer lines that aren't valid syntax. If any lines from the file were removed, it re-writes the file. If no changes were made (no header/footer to remove), it does nothing.
 * @param filePath	The filepath to the YAML or action syntax file.
 * @throws IOException
 * @throws CoreException 
 */
private void createCleanMOOSEFile(String filePath) throws IOException, CoreException {
  String fileExt, execName, fileType=null;
  boolean hasHeader=false, hasFooter=false;
  int headerLine=0, footerLine=0;
  String separator=System.getProperty("String_Node_Str");
  ArrayList<String> fileLines;
  IFolder mooseFolder=project.getFolder("String_Node_Str");
  if (!mooseFolder.exists()) {
    mooseFolder.create(true,true,null);
  }
  fileExt=filePath.substring(filePath.lastIndexOf("String_Node_Str"));
  execName=filePath.substring(filePath.lastIndexOf(separator) + 1,filePath.lastIndexOf(fileExt));
  String cleanFilePath=filePath.substring(0,filePath.lastIndexOf(separator)) + separator + "String_Node_Str"+ separator+ execName+ fileExt;
  if ("String_Node_Str".equals(fileExt)) {
    fileType="String_Node_Str";
  }
 else   if ("String_Node_Str".equals(fileExt)) {
    fileType="String_Node_Str";
  }
 else {
    System.out.println("String_Node_Str" + "String_Node_Str" + fileExt);
  }
  java.nio.file.Path readPath=Paths.get(filePath);
  fileLines=(ArrayList<String>)Files.readAllLines(readPath,Charset.defaultCharset());
  String header="String_Node_Str" + fileType + "String_Node_Str";
  String footer="String_Node_Str" + fileType + "String_Node_Str";
  hasHeader=fileLines.contains(header);
  hasFooter=fileLines.contains(footer);
  if (hasFooter) {
    footerLine=fileLines.indexOf(footer);
    int i=footerLine;
    while (i < fileLines.size()) {
      fileLines.remove(i);
    }
  }
  if (hasHeader) {
    headerLine=fileLines.indexOf(header);
    for (int i=headerLine; i >= 0; i--) {
      fileLines.remove(i);
    }
  }
  if (hasHeader || hasFooter) {
    IFile cleanFile=mooseFolder.getFile(execName + fileExt);
    if (cleanFile.exists()) {
      cleanFile.delete(true,null);
    }
    java.nio.file.Path writePath=Paths.get(cleanFilePath);
    Files.write(writePath,fileLines,Charset.defaultCharset(),StandardOpenOption.CREATE);
    System.out.println("String_Node_Str" + "String_Node_Str" + execName + fileExt);
    File oldFile=new File(filePath);
    oldFile.delete();
  }
  return;
}