fixed while loop in getLine() to stop at the appropriate time