Repository: apple/pkl
File: pkl-cli/src/main/kotlin/org/pkl/cli/CliEvaluator.kt (Kotlin)

Code before:
        )
      }
      val absolutePath = workingDir.resolve(substituted).normalize()
      absolutePath
    }
  }

  /** Renders each module's `output.text`, writing it to the specified output file. */
  private fun writeOutput(builder: EvaluatorBuilder) {
    val evaluator = builder.setOutputFormat(options.outputFormat).build()
    evaluator.use {
      val outputFiles = fileOutputPaths
      if (outputFiles != null) {
        // files that we've written non-empty output to
        // YamlRenderer produces empty output if `isStream` is true and `output.value` is empty
        // collection
        val writtenFiles = mutableSetOf<Path>()

        for ((moduleUri, outputFile) in outputFiles) {
          val moduleSource = toModuleSource(moduleUri, consoleReader)
          val output = evaluator.evaluateExpressionString(moduleSource, options.expression)
          outputFile.createParentDirectories()
          if (!writtenFiles.contains(outputFile)) {
            // write file even if output is empty to overwrite output from previous runs
            outputFile.writeString(output)
            if (output.isNotEmpty()) {
              writtenFiles.add(outputFile)
            }
          } else {
            if (output.isNotEmpty()) {
              outputFile.writeString(
                options.moduleOutputSeparator + '\n',
                Charsets.UTF_8,
                StandardOpenOption.WRITE,
                StandardOpenOption.APPEND,
              )
              outputFile.writeString(
                output,
                Charsets.UTF_8,
                StandardOpenOption.WRITE,
                StandardOpenOption.APPEND,
              )
            }
          }
        }
      } else {
        var outputWritten = false
        for (moduleUri in options.base.normalizedSourceModules) {
          val moduleSource = toModuleSource(moduleUri, consoleReader)
          val output = evaluator.evaluateExpressionString(moduleSource, options.expression)
          if (output.isNotEmpty()) {

Review comment (suggestion):
```suggestion
                "Did you mean `--multiple-file-output-path` / `-m`?"
```

Maybe? 🤔 

Code after:
            "because module `$uri` does not have a file system path."
        )
      }
      val absolutePath = workingDir.resolve(substituted).normalize()
      absolutePath
    }
  }

  /** Renders each module's `output.text`, writing it to the specified output file. */
  private fun writeOutput(builder: EvaluatorBuilder) {
    val evaluator = builder.setOutputFormat(options.outputFormat).build()
    evaluator.use {
      val outputFiles = fileOutputPaths
      if (outputFiles != null) {
        // files that we've written non-empty output to
        // YamlRenderer produces empty output if `isStream` is true and `output.value` is empty
        // collection
        val writtenFiles = mutableSetOf<Path>()

        for ((moduleUri, outputFile) in outputFiles) {
          val moduleSource = toModuleSource(moduleUri, consoleReader)
          val output = evaluator.evaluateExpressionString(moduleSource, options.expression)
          if (Files.isDirectory(outputFile)) {
            throw CliException(
              "Output file `$outputFile` is a directory. " +
                "Did you mean `--multiple-file-output-path`?"
            )
          }
          outputFile.createParentDirectories()
          if (!writtenFiles.contains(outputFile)) {
            // write file even if output is empty to overwrite output from previous runs
            outputFile.writeString(output)
            if (output.isNotEmpty()) {
              writtenFiles.add(outputFile)
            }
          } else {
            if (output.isNotEmpty()) {
              outputFile.writeString(
                options.moduleOutputSeparator + '\n',
                Charsets.UTF_8,
                StandardOpenOption.WRITE,
                StandardOpenOption.APPEND,
              )
              outputFile.writeString(
                output,
                Charsets.UTF_8,
                StandardOpenOption.WRITE,
                StandardOpenOption.APPEND,
              )
            }
          }