Modified NMAP script: variable ‘host’ is not declared

I am modifying an nse script, ssl-cert.nse, which was already made for enumerating ssl certificates. I want to output the host ip and the port number in a line of the ssl certificate output. However, any time I try to make a call to host.ip or port.number, it appears that host and port are undeclared variables. How can I output the current host ip and port number of the detected ssl service. Preferably I could concatenate the host and port number inside of the certificate data output. Below is the area of code I have modified / added to in the ssl-cert.nse script file.

        local out1 = host.ip         local out2 = port.number          output = function(host, port)            out1 = host.targetName           return host.ip         end         output2 = function(host, port)           out2 = port.number           return port.number          end        if nmap.verbosity() > 0 then         lines[#lines + 1] = "Issuer: " .. stringify_name(cert.issuer)       end        if nmap.verbosity() > 0 then          lines[#lines + 1] = "Public Key type: " .. cert.pubkey.type .. " " .. out1 .. ":" .. out2         lines[#lines + 1] = "Public Key bits: " .. cert.pubkey.bits         lines[#lines + 1] = "Signature Algorithm: " .. cert.sig_algorithm       end        lines[#lines + 1] = "Not valid before: " ..       date_to_string(cert.validity.notBefore)       lines[#lines + 1] = "Not valid after:  " ..       date_to_string(cert.validity.notAfter)