Updated add_file to manage and assign file ids.