There are two different for loops in Lua. You are mixing them together.
Numerical for:
for i=1,10 do -- or e.g. i=10,1,-1
-- do something
end
Generic for:
for k,v in pairs(t) do -- or ipairs, or completely custom functions
-- do something
end
For more information please refer to:
Your problem
To achieve your goal you could wrap gmatch with another iterator or... just go with the most straight-forward and simple solution: count the lines you have processed:
local n = 1
for l in webdata:gmatch("(.-)\n") do
-- do something
n = n + 1
if n > 10 then
break
end
end
It's not the most elegant one, but it works.