Fixed error occuring with redirected output