modified script to take user args and guard against bad files