what is the income code in box 1? Were you in the US on a visa in the past or are you a permanent resident/citizen?
OK. I was definitely not in the US at all for 2016 so I am assuming I would not meet the substantial presence test. Where would I get this form and would I be able to file online at all?
You can download it from the IRS website and would have to send it by regular mail. <a rel="nofollow" target="_blank" href="https://www.irs.gov/uac/form-1040nr-u-s-nonresident-alien-income-tax-return">https://www.irs.gov/uac/form-1040nr-u-s-nonresident-alien-income-tax-return</a>
One more thing, one of the copies of the form 1040-S says attach to state tax return I file. So do I also need to file another form for state?
no, since you weren't in the US at all, you do not need to file a state return