adding loop that writes times as csv file