While the text looks the same in both instances, it could have non-printable characters or terminal command chars that you can't normally see. On Linux you can use cli tools like `od` to inspect output in detail, e.g.: $ nim r program.nim | od -a 0000000 nl C o n t e n t - D i s p o s i 0000020 t i o n : sp f o r m - d a t a ; 0000040 sp n a m e = " f i l e 1 " ; sp f 0000060 i l e n a m e = " p r i c e _ l 0000100 i s t . t x t " nl C o n t e n t 0000120 - T y p e : sp t e x t / p l a i 0000140 n nl nl $ 2 5 sp ( 5 t h sp l i n e 0000160 sp o f sp v a r C h u n k ) Run
Or, if you're absolutely sure input data uses 'n' for line separation, you can just count newlines and remove enough chars from beginning using `strutils.delete`: import std/strutils proc removePrefixLines(s: var string, n: Positive) = var ind, lines = 0 while lines < n: if s[ind] == '\n': inc lines inc ind s.delete(0..ind-1) varChunk.removePrefixLines(4) echo varChunk Run