use recursion of line numbers instead of for loop