fix leaking file handle in auto_db