Fix EOL problem for Windows

EOL characters for Windows and Unix systems are different. Using \n as the EOL character causes some problems in Windows, such as bad code generation. In order to fix those issues detect the current OS and use the corresponding EOL character.