They keep voting until someone has 218 votes
Freepersup posted the longest time it took (I think 2 months) that was from the 1850s I believe.
“After two months and 133 ballots…”
https://history.house.gov/Historical-Highlights/1851-1900/The-longest-and-most-contentious-Speaker-election-in-its-history/