If you experiment with redirecting the output of commands to files, you may find that error messages are still written to your terminal instead of the destination you specified:
$ grep pattern myfile /nonexistent > matches grep: /nonexistent: No such file or directory
This is an intentional design feature of Unix-like operating systems, not just the bash program; it's to separate the output of commands (standard output, or stdout) from any error messages the command may also generate (standard error, or stderr). It's very common for commands to emit both output and error messages, so that the person running the script can read the errors without it interfering with any output from the script.
If you want to redirect error messages as well, the syntax is slightly different; you need to link the redirection operator with the standard error stream...