Add missing import and move `inpath` code below `infile`, which it depends on.