```python
from langchain.document_loaders import UnstructuredPDFLoader

loader = UnstructuredPDFLoader("example_data/layout-parser-paper.pdf")
data = loader.load()

output_file = "extracted_text.txt"

# Open the file in write mode and write the extracted text to it
with open(output_file, "w") as file:
    file.write(data["text"])
```

注：ファイルを上書きする代わりにテキストを追加したい場合は、`"w"`を`"a"`に変更してください。
```python
from langchain.document_loaders import UnstructuredPDFLoader

loader = UnstructuredPDFLoader("example_data/layout-parser-paper.pdf")
data = loader.load()

output_file = "extracted_text.txt"

# Open the file in write mode and write the extracted text to it
with open(output_file, "w") as file:
    file.write(data["text"])
```

Note: If you want to append text to a file instead of overwriting it change the letter `"w"` to the letter `"a"`.