You can also specify the app to open using the -a flag and specifying the full name of the app (with correct spacing and capitalization), e.g.:
open -a 'TextEdit' foobar.txt
open -a 'TextMate' foobar.txt