This weekend I wanted to fly an American flag from the trailing edge of my main sail at the end of my gaff.

Like this (this is not my boat; I have a small wooden catboat!):
https://sos.maryland.gov/PublishingImages/ensign.jpg

It's easy to attach to the end of the gaff, as I've got a hole on the gaff that we connect the sail to. My question is how you attach the flag to the sail at the bottom? Anyone have any tips?