title: Error: bad argument #1 to 'strfind' (string expected, got nil) in Lua
body: <p>This is the code:</p>
  
  <pre><code>local function scanwhite (str, pos)
    while true do
      pos = strfind (str, "%S", pos)
      if not pos then return nil end
      local sub2 = strsub (str, pos, pos + 1)
      if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then
        -- UTF-8 Byte Order Mark
        pos = pos + 3
      elseif sub2 == "//" then
        pos = strfind (str, "[\n\r]", pos + 2)
        if not pos then return nil end
      elseif sub2 == "/*" then
        pos = strfind (str, "*/", pos + 2)
        if not pos then return nil end
        pos = pos + 2
      else
        return pos
      end
    end
  end
  </code></pre>
  
  <p>I'm not an experienced "scripter" so i can't really figure out how to solve this.</p>