Added the necessary code to do file redirection.