public static void stripFileFromWrap(File file, String wrap)
          throws FileNotFoundException, IOException, Exception {
    BufferedReader in = null;
    BufferedWriter out = null;
    File _file = new File(file.getAbsolutePath() + "~");
    
    if (file.exists()) {
      log("    Stripping from " + wrap);
      //log(">>> File DOES exist: " + file.getAbsolutePath());
      try {
        in = new BufferedReader(new FileReader(file));
        FileWriter fw = new FileWriter(_file);
        out = new BufferedWriter(fw);
        stripFromWrap(in, out, wrap);
        
        out.close();
        in.close();
        
        log(">>> Merged to: " + file.getAbsolutePath());
        
        if (!_file.renameTo(file)) {
          //lets try harder...
          log("Renaming failed (it may happen on some systems),"
                  + " directly copying over...");
          try {
            log("Copying " + _file.getAbsolutePath() + " to "
                    + file.getAbsolutePath());
            copyTo(_file, file);
          } catch (IOException e) {
            String msg = " Could not copy over the file nor delete tmp!"
                + "\ntmp path:"+ _file.getAbsolutePath() + "\nreal: "
                + file.getAbsolutePath();
            log(e.getMessage());
            throw (new Exception(msg));
          }
        }
      } finally {
        if (out != null) {
          out.close();
        }
        if (in != null) {
          in.close();
        }
        
        log("Cleaning. Deleting tmp file... " + _file.getAbsolutePath());
        
        _file.delete();
        _file = null;
      }
    } else {
          log(">>> File DOES NOT exist! Some of js files may"
             + " point to dependencies that do not match -s and"
             + " --js-deps-prefix  directory! Use -vv and see whats missing."
             + "\n    File failed to open: "
             + file.getAbsolutePath());
    }
  }