So I did some testing, both writing the problem directly without randomizing and copying one of the working files and changing the text so that it matched one of the non-working. Both of these methods worked.
That made me think that there had to be some problem with the encoding, and sure enough the problems that didn't work had CRLF line terminators while the working problems didn't.
So after changing encoding to just UTF-8 Unicode text the other problems also work!
Have to try this on our production server as well but it seems like this solves the issue.
Thank you for all the help!