diff --git a/template/script.sh.erb b/template/script.sh.erb
index 961fdf679342f5cb01ae9e76881606a4de5474ac..22b7125ea1371a23712ec800612e5b7240c96a27 100755
--- a/template/script.sh.erb
+++ b/template/script.sh.erb
@@ -31,7 +31,7 @@ module load <%= context.cuda_toolkit %>
 # Load the required environment
 module load <%= context.version %>
 
-<%= context.custom_environment %>
+<%= context.custom_environment.gsub(/\r\n?/, "\n") %>
 # Launch MATLAB
 module list
 set -x