For your reference, I am 61 years old, have been involved with computers in one way or another since 1978.
Youngster :-)
Sorry, I didn't have very much time this morning since I was committed to some volunteering work.
Basically, there are several possible levels in the filehandling hierarchy.
At the lowest level, you can use OS-specific calls that work with handles. For example on Linux you'd import BaseUnix and then have fpOpen() etc.; I believe that a Mac uses an OS derived from the BSD family so it would have something similar if not identical.
At a slightly higher level you could use FileOpen(), which similarly returns a handle which you subsequently use for data handling passing the address and size of a data block.
At a higher level, you could use Assign(), Reset() and Rewrite(). These work with a variable generally declared as "file of sometype", where the size of sometype determines the record size on disc. This is one of the two filehandling types you will find in books on what I might call "traditional Pascal", and if you have mainframe experience corresponds to the fixed-length record structure inherited from batch systems (i.e. cards etc.).
Alternatively. you could use Assign() etc. with a variable of type text, which is where your Flush() comes in. This is the other traditional filehandling API, and is used with WriteLn() etc., records are inherently variable-length and textfiles aren't seekable.
Then there's streams, which a lot of people prefer these days.
Finally, there's the much higher level access methods associated with database APIs, i.e. SQL etc., hence somebody's comment that you wouldn't normally do an explicit flush of a database file (I think they were misled by the name of your dbName variable). I'd urge you to consider using a backend SQL database (SQLite, PostgreSQL etc.) if data integrity is important, or if there is any chance whatsoever that more than one program or user will need simultaneous access.
HTH.
MarkMLl