getline function using for loop