swap order of redirects

- you need to dup2 before redirecting