### Bug description

Code is run twice (atleast for the `book` project) on `quarto render`. In the MWE below, the code appends `"Test"` to a file called `text.txt`. Starting by removing `text.txt` and running `quarto render` once leads to the file having `TestTest`, where it should just be `Test`.

[test.zip](https://github.com/quarto-dev/quarto-cli/files/11197283/test.zip)

Output of `quarto check`
```
❯ quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.313
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.9 (Conda)
      Path: /home/dhruva/.julia/conda/3/x86_64/bin/python3.10
      Jupyter: 5.2.0
      Kernels: julia-1.9, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
```

<details>
<summary>
Output of quarto render
</summary>
<pre><code>
❯ quarto render
[1/4] index.qmd
[2/4] intro.qmd

Starting python3 kernel...Done

Executing 'intro.ipynb'
  Cell 1/1...Done


Starting python3 kernel...Done

Executing 'intro.ipynb'
  Cell 1/1...Done

[3/4] summary.qmd
[4/4] references.qmd

pandoc 
  to: latex
  output-file: index.tex
  standalone: true
  toc: true
  number-sections: true
  top-level-division: chapter
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf
  
metadata
  crossref:
    chapters: true
  documentclass: scrreprt
  papersize: letter
  classoption:
    - DIV=11
    - numbers=noendperiod
  header-includes:
    - '\KOMAoption{captions}{tableheading}'
  block-headings: true
  bibliography:
    - references.bib
  title: test
  author: Norah Jones
  date: 4/11/2023
  
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023/Arch Linux) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
running xelatex - 2
  This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023/Arch Linux) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  

Output created: _book/index.html
</code></pre>
</details>
</summary>


### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
- [X] Please provide the output of `quarto check` so we know which version of quarto and its dependencies you're running.
dragonstyle
2023-04-11T06:23:52Z
DhruvaSambrani
closed
Code is run again for every output type in a book project
https://github.com/quarto-dev/quarto-cli/issues/5150