Added write database to file