In modern bash, this case is already protected with the "noclobber" option (enabled with "set -C" or "set -o noclobber"). It is described in the "REDIRECTION" section of bash(1), subsection "Redirecting Output".
It fails ">" redirections with an error message when it would clobber an existing file (you probably wanted to append to the file wiht ">>"). If you really intended this behavior, the new redirection operator '>|' has the old behavior.
$ set -o noclobber
$ echo foo > bar
$ cat bar
foo
$ cat bar > bar
bash: bar: cannot overwrite existing file
$ echo baz > bar
bash: bar: cannot overwrite existing file
$ echo baz >| bar
$ cat bar
baz
edit: fixed typo