I removed all files in a directory and then ran ls > foo in that same directory.
Running cat foo reveals that the newly created file "foo" contains "foo". Why is the file "foo" not empty? When ls executes, there are no files in the directory yet, right?