It is your hand earned money, which you propose to invest.
Don't you think it necessary to consult a lawyer in your area and take his views and help?
Have you ascertained whether the builder is ready to make the registration in your favour/name? Or whether he has any objections?
Whether the builder has to get any outstanding amount/consideration from the first buyer?
What is the reason why the builder has not so far made the registration in favour of the first purchaser, even though he has handed over possession of the flat?
Whether you are going to avail any home loan? Whether the banker or financial institution from whom you are going to get the loan is comfortable with the arrangement/purchase that you are proposing?
Whether you have to pay more amount to the first buyer (for selling his flat to you), than what he had paid to the builder? If so, how you will show this in your document? For, the builder will not be ready to put any amount, which is more than what he got from the first buyer.
Therefore, without thinking/discussing these issues, asking a simple question as you have posed here, will not get you the ultimate ideal answer. If you proceed with half answer, then you will repent later.
Therefore, you will be advised to get in touch with a lawyer in your locality.