public static @NotNull ThrowableConsumer<OutputStream, IOException> writeLines(@NotNull Collection<String> lines,
                                                                        @NotNull String separator,
                                                                        @NotNull Charset charset,
                                                                        boolean endWithSecondSeparator) {
    return stream -> {
      OutputStreamWriter writer = new OutputStreamWriter(stream, charset);
      try {
        for (String line : lines) {
          writer.write(line);
          writer.write(separator);
        }
        if (endWithSecondSeparator) writer.write(separator);
        writer.flush();
      }
      finally {
        if (!SystemInfo.isWindows || !endWithSecondSeparator) writer.close();
      }
    };
  }
public static @NotNull ThrowableConsumer<OutputStream, IOException> writeLines(@NotNull Collection<String> lines,
                                                                        @NotNull String separator,
                                                                        @NotNull Charset charset,
                                                                        boolean endWithSecondSeparator)