break line node.js using fs

0

I need to print the variable result with line break in a txt file, I have the following code:

var Resultado = formatters.addTrailingZeros(req.query.Nrbanco, 3)        + 
    '0000'                                                              + 
    '0'                                                                 + 
    formatters.addEspacos(' ', 9)                                       + 
    formatters.addTrailingZeros(req.query.TipoInscricao, 1)             + 
    formatters.addTrailingZeros(req.query.IncricaoCedente, 15)          + 
    formatters.addTrailingZeros(req.query.Convenio, 20)                 + 
    formatters.addTrailingZeros(req.query.Agencia , 5)                  + 
    formatters.addTrailingZeros(req.query.AgenciaDigito , 1)            + 
    formatters.addTrailingZeros(req.query.Conta , 12)                   + 
    formatters.addTrailingZeros(req.query.ContaDigito , 1)              + 
    ' '                                                                 + 
    formatters.addTrailingZeros(req.query.Cedente , 30)                 + 
    formatters.addEspacos('CEDRED' , 30)                                + 
    formatters.addEspacos(' ', 10)                                      + 
    '1'                                                                 + 
    formatters.addTrailingZeros(req.query.DataGeracaoArquivo , 8)       + 
    formatters.addTrailingZeros(req.query.HoraGeracaoArquivo , 6)       + 
    formatters.addTrailingZeros(req.query.NumeroRemessa, 6)             + 
    '087'                                                               + 
    formatters.addTrailingZeros(0, 5)                                   + 
    formatters.addEspacos(' ', 20)                                      + 
    formatters.addEspacos(' ', 20)                                      + 
    formatters.addEspacos(' ', 29);                   

// Aqui preciso inserir uma quebra de linha já tentei o \n e não funcionou

Resultado = Resultado +
    formatters.addTrailingZeros(req.query.Nrbanco, 3)                   + 
    '0001'                                                              + 
    '1'                                                                 + 
    'R'                                                                 + 
    '01'                                                                + 
    '  '                                                                + 
    '045'                                                               + 
    ' '                                                                 + 
    formatters.addTrailingZeros(req.query.TipoInscricao, 1)             + 
    formatters.addTrailingZeros(req.query.IncricaoCedente, 15)          + 
    formatters.addTrailingZeros(req.query.Convenio, 20)                 + 
    formatters.addTrailingZeros(req.query.Agencia, 15)                  + 
    formatters.addTrailingZeros(req.query.AgenciaDigito , 1)            + 
    formatters.addTrailingZeros(req.query.Conta , 12)                   + 
    formatters.addTrailingZeros(req.query.ContaDigito , 1)              + 
    ' '                                                                 + 
    formatters.addEspacos(req.query.Cedente , 30)                       + 
    formatters.addEspacos(' ', 40)                                      + 
    formatters.addEspacos(' ', 40)                                      + 
    formatters.addTrailingZeros(req.query.NumeroRemessa, 8)             + 
    formatters.addTrailingZeros(req.query.DataGeracaoArquivo , 8)       + 
    formatters.addTrailingZeros('0' , 8)                                + 
    formatters.addTrailingZeros('0' , 33);                                

var stream = fs.createWriteStream ("C: /16/remessa.txt");    stream.once ('open', function (fd) {         stream.write (Result);         stream.end ();    });

I've tried other ways to print this variable in txt format by breaking line and I did not succeed, thank you if anyone has any suggestions.

    
asked by anonymous 31.07.2017 / 19:26

1 answer

2

Have you tried concatenating \r\n at the end of what you want each line to be?

    
31.07.2017 / 21:23