I tested this using a couple of random txt files. I confirmed the problem on very short txt files. But it works when I add more content to the file. So this problem might be related to the length of the file.
I started by testing "test.txt" which contained only the 4 character word, "test". It gave me an error when trying to upload that file. Then I added several more lines to the file and it worked.
The "htaccess.txt" file worked fine.
Also note that the attachment system allowed me to upload the same file twice (htaccess.txt). A duplicate check might be a good idea.
Read the contents of the file and use GD to create a thumbnail representing the top left corner of file when viewing it in a text editor. I was just kidding, but now that I think about it, I'm kinda halfway serious. Could be a nice touch.