Close the database before reading its contents

In Database.export, the contents of the database has to be flushed to
the db file before the contents of the file are read and returned.

Fix #9
Fix #55
Compilation of the last commit