--- /Users/dross/Desktop/xmlsitemap/xmlsitemap.admin.inc	2010-04-29 22:31:25.000000000 -0500
+++ xmlsitemap/xmlsitemap.admin.inc	2010-12-23 14:16:12.000000000 -0600
@@ -372,6 +372,11 @@ function xmlsitemap_settings_form() {
   foreach ($form['advanced']['xmlsitemap_lastmod_format']['#options'] as $key => &$label) {
     $label .= ' (' . gmdate($key, REQUEST_TIME) . ')';
   }
+  $form['advanced']['xmlsitemap_linebreaks'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Remove linebreaks from the sitemap.'),
+    '#default_value' => variable_get('xmlsitemap_linebreaks', 0),  
+  );
   $form['advanced']['xmlsitemap_developer_mode'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable developer mode to expose additional settings.'),

--- /Users/dross/Desktop/xmlsitemap/xmlsitemap.generate.inc	2010-04-29 11:22:09.000000000 -0500
+++ xmlsitemap/xmlsitemap.generate.inc	2010-12-23 14:35:29.000000000 -0600
@@ -222,6 +222,19 @@ function xmlsitemap_generate(array $site
 }
 
 /**
+ * Get the desired EOL character for generating sitemaps
+ * @return string End of line character/string
+ */
+function xmlsitemap_generate_eol() {
+  if(!variable_get('xmlsitemap_linebreaks', 0)) {
+    return PHP_EOL;
+  }
+  else {
+    return '';
+  }
+}
+
+/**
  * Write the proper XML sitemap header.
  *
  * @param $sitemap
@@ -232,22 +245,24 @@ function xmlsitemap_generate(array $site
  * @param $status
  */
 function xmlsitemap_generate_chunk_header($type, array $sitemap, $handle, &$status) {
-  $output = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
+  $EOL = xmlsitemap_generate_eol();
+  
+  $output = '<?xml version="1.0" encoding="UTF-8"?>' . $EOL;
 
   // Add the stylesheet link.
   if (variable_get('xmlsitemap_xsl', 1)) {
     $xsl_url = url('sitemap.xsl', $sitemap['uri']['options'] + array('alias' => TRUE));
-    $output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . PHP_EOL;
+    $output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_url . '"?>' . $EOL;
   }
 
-  $output .= '<' . $type . ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
+  $output .= '<' . $type . ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . $EOL;
 
   // This is the full XML header required for schema validation.
   //$schemas = array('sitemapindex' => 'siteindex.xsd', 'urlset' => 'sitemap.xsd');
-  //$output .= '<' . $type . ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . PHP_EOL;
-  //$output .= '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . PHP_EOL;
-  //$output .= '  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . PHP_EOL;
-  //$output .= '  http://www.sitemaps.org/schemas/sitemap/0.9/' . $schemas[$type] . '">' . PHP_EOL;
+  //$output .= '<' . $type . ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . $EOL;
+  //$output .= '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . $EOL;
+  //$output .= '  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . $EOL;
+  //$output .= '  http://www.sitemaps.org/schemas/sitemap/0.9/' . $schemas[$type] . '">' . $EOL;
 
   $status &= (bool) fwrite($handle, $output);
   return $status;
@@ -267,6 +282,8 @@ function xmlsitemap_generate_chunk_heade
  *   An integer representing the integer of the sitemap page chunk.
  */
 function xmlsitemap_generate_chunk(array $sitemap, $handle, &$status, $chunk) {
+  $EOL = xmlsitemap_generate_eol();
+    
   $lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
 
   $url_options = $sitemap['uri']['options'];
@@ -346,11 +363,12 @@ function xmlsitemap_generate_chunk(array
       // sitemaps.org specification.
       $link_output .= '<priority>' . number_format($link['priority'], 1) . '</priority>';
     }
-    $link_output .= '</url>' . PHP_EOL;
+    $link_output .= '</url>' . $EOL;
     $status &= (bool) fwrite($handle, $link_output);
   }
 
   // Close the XML file.
+  // Has to be PHP_EOL per issue 660580 & xmlsitemap-n660580.patch
   $status &= (bool) fwrite($handle, '</urlset>' . PHP_EOL);
 
   return $link_count;
@@ -366,6 +384,8 @@ function xmlsitemap_generate_chunk(array
  * @param $status
  */
 function xmlsitemap_generate_index(array $sitemap, $handle, &$status) {
+  $EOL = xmlsitemap_generate_eol();
+  
   $lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
 
   $url_options = $sitemap['uri']['options'];
@@ -385,12 +405,12 @@ function xmlsitemap_generate_index(array
     $output .= '<loc>' . url('sitemap.xml', $url_options) . '</loc>';
     // @todo Use the actual lastmod value of the chunk file.
     $output .= '<lastmod>' . gmdate($lastmod_format, REQUEST_TIME) . '</lastmod>';
-    $output .= '</sitemap>' . PHP_EOL;
+    $output .= '</sitemap>' . $EOL;
     $status &= (bool) fwrite($handle, $output);
   }
 
   // Close the XML file.
-  $status &= (bool) fwrite($handle, '</sitemapindex>' . PHP_EOL);
+  $status &= (bool) fwrite($handle, '</sitemapindex>' . $EOL);
 
   return $sitemap['chunks'];
 }
