Two-step Evolution of a Rising Flux Rope Resulting in a Confined Solar Flare