A reasonable start with a few "issues"...
First, by just using dir you'll get the null directory entries as well as files, if you want all the files and they are .txt, use the wild card to get only files back...presuming, of course, you don't name folders with a '.txt' extension! :)
After that, fopen does not return any data; it only gives you a file handle for functions like textscan or fscanf to actually read the file. However, with a plain text file, there are higher-level functions that will read the file directly from the file name to even dispense with it... dlmread or importdata are two (altho the latter calls the former)...
The above will concatenate all data into one long file; if you need to keep them separated, then create a new file name in the loop based on the existing or some other name convention.