"and all those who live on the earth will worship the beast, everyone whose name has not been written since the foundation of the world in the book of life belonging to the Lamb who was killed."
"The prepositional phrase 'since the foundation of the world' is traditionally translated as a modifier of the immediately preceding phrase in the Greek text, 'the Lamb who was killed' (so also G. B. Caird, Revelation [HNTC], 168), but it is more likely that the phrase 'since the foundation of the world' modifies the verb 'written' (as translated above). Confirmation of this can be found in Rev 17:8 where the phrase 'written in the book of life since the foundation of the world' occurs with no ambiguity" (NET Footnote).
καὶ προσκυνήσουσιν αὐτὸν πάντες οἱ κατοικοῦντες ἐπὶ τῆς γῆς, οὗ οὐ γέγραπται τὸ ὄνομα αὐτοῦ ἐν τῷ βιβλίῳ τῆς ζωῆς τοῦ ἀρνίου τοῦ ἐσφαγμένου ἀπὸ καταβολῆς κόσμου (WH of 1881)
Picture used with kind permission from http://bibleencyclopedia.com/nasb/NASB_Revelation_13-8.jpg