 This is a Phase II trial to determine the efficacy and safety of in situ gene therapy and stereotactic body radiation therapy SBRT used as a window of opportunity treatment before nivolumab in patients with metastatic squamous and non-squamous non-small cell lung carcinoma NSCLC. In situ gene therapy will consist of adenovirus-mediated expression of herpes simplex virus thymidine kinase ADVHSV-tk plus Valacyclovir therapy. Male or female patients aged 18 years with histologically or cytologically confirmed metastatic squamous or non-squamous NSCLC whose disease has progressed after a platinum-based chemotherapy and a single-agent immunotherapy are eligible to participate in the study. Patients with EGFR or ALK genomic tumor aberrations are eligible only if they have had disease progression on FDA-approved therapy for these aberrations. ADVHSV-tk 5 x 1011 viral particles in a 2-mL total volume will be injected intratumorally on day 0 of the study. Valacyclovir will be orally administered at a dose of 2 g three times daily for 14 days. Valacyclovir treatment will be administered 24 hours after the gene vector injection from day 1 to day 15 of the study. SBRT of 30 gray Gy; 6 Gy X 5 fractions will be administered over 2 weeks from day 2 to day 16 of the study. Nivolumab 240 mg will be administered intravenously over 60 minutes every 2 weeks starting on day 17 of the study and continuing until disease progression, unacceptable toxicity, or up to 12 months in patients without disease progression. The primary endpoint will be the objective response rate ORR of ADVHSV-tk Valacyclovir therapy in combination with SBRT used as a window of opportunity treatment before nivolumab in patients with metastatic squamous or non-squamous NSCLC. Both RECIST 1.1 and modified immune-related response criteria irRC; derived from RECIST 1.1 will be used to assess treatment response. Secondary endpoints will include a duration of response DoR; b overall survival OS and progression-free survival PFS rates; c safety and toxicity toxicity will be defined as any treatment-related death or any grade 3 toxicity excluding alopecia and constitutional symptoms as assessed by the NCI CTCAE v4.03; and d immune-mediated antitumor activity assessed by RECIST 1.1 and modified irRC of ADVHSV-tk plus Valacyclovir therapy in combination with SBRT used as a window of opportunity treatment before nivolumab. 