added N_final array, prints to output file