corrected file checking

previously used which when I should have used ls

fixes 93e40074f8f9e98b39b9bdfb1c35bf20d61106ff