this will crash if you don't specify a type on the command line.  you probably want to just re-use the `file_type` variable from line 176.