opened database and close database after every read stream