Fixed add_file function