- j = fread(buffer, 1, sizeof(buffer), data_file);
+ uschar * s;
+
+ if (!f.spool_file_wireformat || source_file_override)
+ j = fread(buffer, 1, sizeof(buffer), l_data_file);
+ else /* needs CRLF -> NL */
+ if ((s = US fgets(CS buffer, sizeof(buffer), l_data_file)))
+ {
+ uschar * p = s + Ustrlen(s) - 1;
+
+ if (*p == '\n' && p[-1] == '\r')
+ *--p = '\n';
+ else if (*p == '\r')
+ ungetc(*p--, l_data_file);
+
+ j = p - buffer;
+ }
+ else
+ j = 0;