Added code to file redirection: Not quite working yet.