private void writeToFile(@NotNull VirtualFile ignoreFileRoot, @NotNull File ignoreFile, @NotNull String ignoreFileContent, boolean openFile) {
    boolean append = ignoreFile.exists();
    String projectCharsetName = EncodingProjectManager.getInstance(myProject).getDefaultCharsetName();
    try {
      if (append) {
        FileUtil.writeToFile(ignoreFile, (lineSeparator() + ignoreFileContent).getBytes(projectCharsetName), true);
      }
      else {
        //create ignore file with VFS to prevent externally added files detection
        WriteAction.runAndWait(() -> {
          VirtualFile newIgnoreFile = ignoreFileRoot.createChildData(ignoreFileRoot, ignoreFile.getName());
          VfsUtil.saveText(newIgnoreFile, ignoreFileContent);
        });
      }
    }
    catch (IOException e) {
      LOG.warn("Cannot write to file " + ignoreFile.getPath());
    }
    markIgnoreFileRootAsGenerated(myProject, ignoreFile.getParent());
    LocalFileSystem.getInstance().refreshIoFiles(Collections.singleton(ignoreFile));
    if (openFile) {
      openFile(ignoreFile);
    }
  }
private void writeToFile(@NotNull VirtualFile ignoreFileRoot, @NotNull File ignoreFile, @NotNull String ignoreFileContent, boolean openFile)