In The Fellowship of the Ring, Book I, Chapter 8, "Fog on the Barrow Downs" the night that the hobbits spend in the house of Tom Bombadil before leaving to cross the Barrow Downs is briefly described:
That night they heard no noises. But either in his dreams or out of them, he could not tell which, Frodo heard a sweet singing running in his mind: a song that seemed to come like a pale light behind a grey rain-curtain, and growing stronger to turn the veil all to glass and silver, until at last it was rolled back, and a far green country opened before him under a swift sunrise.
The vision melted into waking; and there was Tom whistling like a tree full of birds; and the sun was already slanting down the hill and through the open window. Outside everything was green and pale gold.
And presumably this was recorded by Frodo writing the story of his journey. And Sam would have read about that vision. And possibly Sam came to the conclusion that Frodo's vision was prophetic, and so later wrote:
And the ship went out into the High Sea and passed on into the West, until at last on a night of rain Frodo smelled a sweet fragrance on the air and heard the sound of singing that came over the water. And then it seemed to him that as in his dream in the house of Bombadil, the grey rain-curtain turned all to silver glass and was rolled back, and he beheld white shores and beyond them a far green country under a swift sunrise.
Sam certainly hoped that was how the journey ended. He certainly wasn't going to write that when they came in sight of the Lonely Island a voice of thunder from the sky said: "So, you dare to bring a mortal to the Undying Lands! Take this!" and then the ship was struck by lightening and exploded.
And it is possible that Sam also had a vision of Frodo's arrival before or after the fact.
Added 09-25-19. Eugene Styer's answer mentions another experience of Frodo's which Frodo should have written down in the Red Book - how else would the modern translator Tolkien ever learn about it - and which could have influenced Sam to write the ending of Frodo's voyage the way he did.