title: why doesn't my file delete no matter why I do?
body: <pre><code>public void removeLine(String s) throws IOException, FileNotFoundException{
  
      File tempFile = new File("temp.txt");
      FileInputStream reader = new FileInputStream(sharkFile);
      Scanner scanner = new Scanner(reader);  
      BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile, true));
  
      String currentLine;
      while(scanner.hasNextLine()){
          currentLine = scanner.nextLine();
          String trimmedLine = currentLine.trim();
          System.out.println(trimmedLine);
          trimmedLine.equals(sharkName);
          if(trimmedLine.equals(sharkName)) continue;
          writer.write(currentLine + System.getProperty("line.separator"));
      }
  
      scanner.close();
      scanner = null;
      reader.close();
      writer.flush();
      writer.close();
      writer = null;
      System.gc();
      if(!sharkFile.delete()){
          System.out.println("Could not delete file d");
          return;
      }
      if(!tempFile.renameTo(sharkFile)){
          System.out.println("Could not rename file");
          return;
      }
  }
  </code></pre>
  
  <p>I've gone through numerous threads on stackoverflow and have implemented those changes but my file just won't delete. Appreciate the help.</p>