The Row_Number field numbers each line item in a detail dataset and is included by default in every report or query dataset. The field name is ROW_NUMBER.
Insert this field into any detail region in the template to number the results in the merged output file. In the below example, the {{ROW_NUMBER}} merge field is placed in the far left column: