fix regenerate_db and newline issue