factoring code (_getline func)