The file survives between app runs. The in-memory list does not. To make them agree, the app loads the file once at startup, and every new transaction is written to both.
PhaseApp not running
📄
transactions.csv
On disk — survives across app runs
⇒
read at start
⇐
append on save
🧠
ArrayList<Transaction>
In memory — empty when the app is off
Walkthrough
Two places, one source of truth. When the app is running, the ArrayList and the file agree. When the app is off, only the file exists. The startup load is the bridge between them. Forget to load — last run’s transactions vanish. Forget to append — this run’s transactions vanish.
Append, don’t overwrite. Writing to the file without append mode erases every transaction from every previous run. Always open the file in append mode when saving a new transaction — add to the end, keep the rest.
Step through the buttons left to right. Notice that “exit” empties the ArrayList but leaves the file untouched, and “restart” brings the list back by reading the file again — including the transaction you added before exiting.