If I understands your question correctly, I think this will solve it:

with jsonlines.open('yourTextFile', mode='a') as writer:
    writer.write(...)

As you mentioned you are overwriting the file, I think this is because you use mode='w' (w = writing) instead of using mode='a' (a = appending)

Answer from Jeppe Spanggaard on Stack Overflow
🌐
Readthedocs
jsonlines.readthedocs.io
jsonlines — jsonlines documentation
jsonlines is a Python library to simplify working with jsonlines and ndjson data.
🌐
PyPI
pypi.org › project › jsonlines
jsonlines · PyPI
Download URL: jsonlines-4.0.0-py3-none-any.whl · Upload date: Sep 1, 2023 · Size: 8.7 kB · Tags: Python 3 · Uploaded using Trusted Publishing? No · Uploaded via: twine/4.0.2 CPython/3.11.5 · See more details on using hashes here. Supported by ·
      » pip install jsonlines
    
Published   Sep 01, 2023
Version   4.0.0
🌐
GitHub
github.com › wbolster › jsonlines
GitHub - wbolster/jsonlines: python library to simplify working with jsonlines and ndjson data · GitHub
jsonlines is a Python library to simplify working with jsonlines and ndjson data.
Starred by 308 users
Forked by 31 users
Languages   Python
🌐
Medium
nicholaszhan.com › line-em-up-a-guide-to-json-lines-7c43215b3b82
Line ’Em Up: A Guide to JSON Lines | by Nicholas Zhan | Medium
February 2, 2024 - # Reading from a JSON Lines file with open('sensor_data.jsonl', 'r') as file: for line in file: data_entry = json.loads(line) # Process each data_entry as a Python dict print(data_entry)
Find elsewhere
🌐
Rowzero
rowzero.com › blog › open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format - Row Zero – the spreadsheet for modern cloud data
October 24, 2024 - Here's example Python code: import json import jsonlines # Load the JSON file with open('data.json', 'r') as f: data = json.load(f) # Write to a JSONL file with jsonlines.open('data.jsonl', mode='w') as writer: for obj in data: writer.write(obj)
🌐
Arch Linux
archlinux.org › packages › extra › any › python-jsonlines
Arch Linux - python-jsonlines 4.0.0-6 (any)
View the file list for python-jsonlines · View the soname list for python-jsonlines · Copyright © 2002-2026 Judd Vinet, Aaron Griffin and Levente Polyák. The Arch Linux name and logo are recognized trademarks. Some rights reserved.
🌐
PyPI
pypi.org › project › json-lines
json-lines · PyPI
Reading JSON lines (jl) files, recover broken files
      » pip install json-lines
    
Published   Nov 21, 2018
Version   0.5.0
🌐
Langchain
js.langchain.com › docs › integrations › document_loaders › file_loaders › jsonlines
Jsonlines files - integration - Docs by LangChain
This example goes over how to load data from JSONLines or JSONL files. The second argument is a JSONPointer to the property to extract from each JSON object in the file. One document will be created for each JSON object in the file.
🌐
Reddit
reddit.com › r/learnpython › faster way to process jsonl file with thousands of json lines
r/learnpython on Reddit: Faster way to process JSONL file with thousands of json lines
July 6, 2023 -

Hello, As the title, I have thousands to millions json lines spread over multiple JSONL format files.
What would be an efficient approach to process those lines and store in a temporary object that I want to index to some application?
Currently I'm thinking to process N lines per batch, index them and repeat until the last line in last file.

🌐
Arch Linux ARM
archlinuxarm.org › packages › aarch64 › python-jsonlines
python-jsonlines (aarch64) | Packages | Arch Linux ARM
Copyright ©2009-2026 Arch Linux ARM The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a world-wide basis. The Arch Linux™ name and logo are used under permission of the Arch Linux Project Lead
🌐
DEV Community
dev.to › scrapfly_dev › jsonl-vs-json-hb0
JSONL vs JSON - DEV Community
December 17, 2024 - Handling JSONLines files involves reading, writing, and appending data efficiently. Here’s how to do it in various programming languages: Python’s jsonlines library simplifies working with JSONL files.
🌐
Jsonlines
jsonlines.org › examples
JSON Lines |Examples
CSV seems so easy that many programmers have written code to generate it themselves, and almost every implementation is different. Handling broken CSV files is a common and frustrating task. CSV has no standard encoding, no standard column separator and multiple character escaping standards.
🌐
Debian
packages.debian.org › unstable › python › python3-jsonlines
Details of package python3-jsonlines in sid
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Anaconda.org
anaconda.org › conda-forge › jsonlines
jsonlines - conda-forge | Anaconda.org
Install jsonlines with Anaconda.org. Library with helpers for the jsonlines file format
🌐
Unpaywall
support.unpaywall.org › support › solutions › articles › 44001867300-how-do-i-read-jsonl-files-
How do I read JSONL files? : Unpaywall
In python, you could either read the file line by line and use the standard json.loads function on each line, or use the jsonlines library to do this for you.