Fixed output redirect for "which"

Credits go to @jalung . Closes #231 .

(cherry picked from commit f89838976d3b11424cb649cd2b6f376579c42d0e)