made fix as per instructor

making outfile global should fix