"How can I be sure my name is written in the Book of Life?"
"I want you to be absolutely confident that the instant after you close your eyes in death, you will see Jesus face to face."
Jesus said that only those who do the will of His Father will enter the Kingdom of heaven. Is Jesus saying we must live a sinless life to be saved? Of course not. Our righteousness cannot save us. Only the righteousness of Jesus can save. The will of the Father is that we commit our lives to the Lord Jesus Christ. Then, whenever we sin, we confess our sin and repent, and He restores us to a full relationship with Him—for He will never forsake us.
Whenever someone says to me, "I hope my name is written in the book of life, but I'm not really sure"—I say, "Well, let's make sure right now, once and for all, so you'll never have to wonder again." I want you to be absolutely confident that the instant after you close your eyes in death, you will see Jesus face to face. I want you to know that your name is inscribed in that book in the indelible lettering of the Lord's own blood.
Confess and repent of your sins to God, and receive Jesus, once and for all, as your Lord and your Savior. Then live every day for Him. When the Day of Judgment comes, you'll have no reason to be ashamed. Your name is in the book.