title: Lua 'end' expected (to close 'function' at line near '<eof>'
body: <p>I cannot find where the missing end is, iI have double checked and triple checked the syntax and its driving me mad. I have tested compilation online and locally so my specific question here is why is the error being thrown?</p>
  
  <p>Here is the error:</p>
  
  <blockquote>
    <p>line 71: 'end' expected (to close 'function' at line 25) near '&lt; eof >'</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>    tArgs = { ... }
  --Argument validation
  if #tArgs &lt; 2 then
    printUsage()
    return
  end
  
  --globals
  local MAX_INV_SLOT = 16
  local depth = tonumber(tArgs[1])
  local bredth = tonumber(tArgs[2])
  
  --Usage output
  local function printUsage()
    print("Usage: &lt;branch depth&gt; &lt;num branches&gt;")
  end
  
  --wrap turtle.forward()
  local function fwd()
   while turtle.forward() == false do
    turtle.dig()
   end
  end
  -- check / get fuels
  local function checkFuel()
    while turtle.getFuelLevel() == 0 do
     for k=0, 16, 1 do
       if turtle.refuel(i) then
         return
       end
     end  
    return
  end
  --mine 1 wide 3 tall segment
  local function step()
   fwd()
   turtle.digUp()
   turtle.digDown()
  end
  
  local function control()
    for i=0, bredth,1 do
      for j=0, depth,1 do
        checkFuel()
        step()
      end
      -- Turn Corner
      if (i % 2) == 0 then
        step()
        turtle.turnRight()
        step()
        step()
        step()
        turtle.turnRight()
      else
        -- Left U turn
        step()
        turtle.turnLeft()
        step()
        step()
        step()
        turtle.turnLeft()
      end
    end
    print("Should be done!")
  end
  
  
  
  control()
  </code></pre>