I discovered the cause of the close() error I was seeing when editing a database entry with vi, then hitting y to continue
When continuing a new entry is expected to be appended to the database
The file was closed and re-opened between executing vi; however, due to the "my" declaration in the open() call an alias of the global filehandle $DATABASE was made
Make sure there is only one $DATABASE variable; now I can correctly append new entries after editing an entry with vi