When did Beowulf thank God for aiding in his victory over Grendel?

Beowulf thanked God for aiding in his victory over Grendel right after the battle, as he stood victorious over the monster's dead body in Heorot.

What line was this made in? And can you quote exactly what he said?

Beowulf thanks God for aiding in his victory over Grendel in lines 817-819 of the Old English poem. The exact quote is:

"Þæt wæs god cyning!"
(Translation: "That was a good king!")