Original TrimNewLines function from the documentation:

; TrimNewlines
; input, top of stack  (e.g. whatever$\r$\n)
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.

Function TrimNewlines
  Exch $R0
  Push $R1
  Push $R2
    StrCpy $R1 0
    loop:
      IntOp $R1 $R1 - 1
      StrCpy $R2 $R0 1 $R1
      StrCmp $R2 "$\r" loop
      StrCmp $R2 "$\n" loop
  IntOp $R1 $R1 + 1

  StrCpy $R0 $R0 $R1
  Pop $R2
  Pop $R1
Exch $R0
FunctionEnd



Revised function:

;-----------------------------
;	TrimCRLF
;	Author: Unknown
;
;	This function trims off trailing CR and LF characters.
;
;	input, top of stack  (e.g. whatever$\r$\n)
;	output, top of stack (replaces, with e.g. whatever)
;	modifies no other variables.
;-----------------------------

Function TrimCRLF
  ;
  ;	Get the string and prep some room.
  Exch $R0
  Push $R1
  Push $R2
  StrCpy $R1 0
  ;
  ;	Work backwards through the string, moving back each time we
  ;	see another CR or LF.
loop:
  IntOp $R1 $R1 - 1
  StrCpy $R2 $R0 1 $R1
  StrCmp $R2 "$\r" loop
  StrCmp $R2 "$\n" loop
  ;
  ;	Finished, so move off the last non-CRLF character, then chop
  ;	off the ones we saw.  If we didn't see any (R1 = 0), then we
  ;	don't need to do any chopping off.
  IntOp $R1 $R1 + 1
  StrCmp $R1 0 TCRLFSkip
  StrCpy $R0 $R0 $R1
TCRLFSkip:
  ;
  ;	Put everybody back and dump the trimmed string on the stack.
  Pop $R2
  Pop $R1
  Exch $R0
FunctionEnd
