^M ─ i.e. Ctrl+M ─ appearing at the end of every line in a plain text file is without any doubt the result of the file having been edited in Microsoft Windows (and/or MS-DOS).
DOS used/uses two characters as the end-of-line, being a newline character and a carriage return. Microsoft Windows has a lot of legacy behavior that it inherited from DOS, and as such it has also adopted this dual-character end-of-line. (Legacy macOS from before OS X in turn used a single carriage return as the end-of-line, without a newline character.)
UNIX systems ─ like GNU/Linux ─ on the other hand use only a single newline character as the end-of-line. Therefore, when opening a text file that has been edited in Microsoft Windows, you get to see the carriage return character Ctrl+M, which is usually represented as a
^M in UTF-8 character encoding, and as a
¶ in ISO-8859-1/ISO-8859-15.
I have seen many botched up configuration files in my time, back when I was running an IRC network with a couple of other people. I myself have been exclusively running GNU/Linux for over 20 years now, but my colleagues were all running Microsoft Windows on their machines, and the servers also ran GNU/Linux. So instead of logging into the servers by way of
ssh and editing the configuration files there, they would simply download the file onto their local Windows PCs, edit it with Windows’ NotePad, and then uploaded the file to the server again by way of
ftp. And that’s when you then got those syntax errors.
Many of the GNU/Linux editors can automatically convert a file with DOS/Windows-style line endings to UNIX line-endings and vice versa, but the
dos2unix command line utility ─ it’s in the Community repository ─ can also be used.