Close the Gaps: A Learning-while-Doing Algorithm for a Class of Single-Product Revenue Management Problems