# Very confused about my PrintWriter object

**URL:** https://discourse.processing.org/t/very-confused-about-my-printwriter-object/27967
**Category:** Coding Questions
**Created:** [February 21, 2021, 12:58am UTC](https://discourse.processing.org/t/very-confused-about-my-printwriter-object/27967 "2021-02-21T00:58:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Math\_Machine](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)
#### Post date: [February 21, 2021, 12:58am UTC](https://discourse.processing.org/t/very-confused-about-my-printwriter-object/27967/1 "2021-02-21T00:58:19Z")

</div>

Okay, so, I’m making a calculator. I started using the PrintWriter and BufferedReader objects so I could save previously entered problems, even after I exit the sketch.

Problem is, it kinda has to save a lot of data to the file. There’s no feasible limit to how long a line could get, and each entry in the line has some attached metadata, which adds even more to the load.

I didn’t realize until now, though, that when your file gets really big, the text saving mechanism kinda messes up. I’ll just see a line in the text file that says “null null null null nu”. It kinda just stops.

I think the flush function might be useful in stopping this…I think? But I can’t tell how often I’m supposed to use the flush function. And, overall, I feel like there’s gotta be a better way to edit the text file than using createWriter to clear the entire file, using a buffered reader to put everything back in the file, and adding the 3 extra lines I needed before closing.
