I am making a function that when it is inputted a long string, it splits it up into several lines. Here is my attempt:

function splitMessage(message)
	local splitMessage = {}
	local threshold = 1
	
	while threshold < #message do
		if string.sub(message, threshold + 35, threshold + 35) == " " then
			table.insert(splitMessage, string.sub(message, threshold, threshold + 34))
			threshold = threshold + 36
		else
			local i = 0
			while (string.sub(message, threshold + (35 - i), threshold + (35 - i)) ~= " ") do
				i = i + 1
			end
			table.insert(splitMessage, string.sub(message, threshold, threshold + 35 - i))
			threshold = threshold + 36 - i 
		end
	end
	
	return splitMessage
end


for i = 1, #splitMessage("Returns an iterator function that, each time it is called, returns the next captures from pattern over string s. If pattern specifies no captures, then the whole match is produced in each call.") do
	print(splitMessage()[i])
end

Whenever the code is run however, it spits out an 'infinite regression' error. Any ideas to (heavily) improve this code?