Harry got the book of the Half Blood Prince by the 6th Book. But when Harry uses the Sectumsempra spell on Draco Malfoy, he ran to the Room of Requirement and had finally decided to hide it there. But Harry soon told Hermione in the 6th book that he will still try to get the book back since it was a big benefit for Harry. But I don't remember any part of the 6th book that he managed to get the book back.
Harry leaves the book in the Room of Requirements, its fate ultimately would be that it burns in book 7 when the room burns down(unless another unknown student finds it between the end of 6 and the end of 7).
below them the cursed fire was consuming the contraband of generations of hunted students, the guilty outcomes of a thousand banned experiments, the secrets of the countless souls who had sought refuge in the room.
You are right in first instance, Harry did not managed to get the book back.
All are some major and minor 7th book spoilers
And so it burned (as well everything in the room) when Crabbe casted Fiendfyre inside the room in The Deathly Hallows.
As you can see here:
"I know what the diadem looks like, and I know where it is,” said Harry, talking fast. “He hid it exactly where I hid my old Potions book, where everyone’s been hiding stuff for centuries. He thought he was the only one to find it. Come on."
There it was, right ahead, the blistered old cupboard in which he had hidden his old Potions book, and on top of it, the pockmarked stone warlock wearing a dusty old wig and what looked like an ancient, discolored tiara.