Skip "enter" value in readchar()


#1

hi there!

I’m reading a .txt file in maxscript
txt file:

1101101
001010

with this script:

  while not eof fileStream do (
  	c = readChar fileStream
  	
  	if c != "\n" then
  	append myArray c
  )

This is what max gives me when I print myArray:
“1”
“1”
“0”
“1”
“1”
“0”
“1”
"
"
“0”
“0”
“1”
“0”
“1”
“0”
“0”

Do you see this empty space between the 2 lines? " "
At first I had 4 of them, I achieve to drop them to 2 with if c != “\n”
But I can’t give a rid of the last 2.

Can you help me out please? thanks


#2

it is the carriage return “\r” char that is left


#3

i’d be inclined to read it in a line by line way

fn filetostring fname =
(
	fstream = openFile fname mode:"rt";
	fstr = undefined;
	if fstream != undefined then
	(
		fstr = "";
		while not eof fstream do fstr += readline fstream;
	)
	fstr;
)


fstr = filetostring "c:/test.txt"
for i = 1 to fstr.count do print fstr[i]

#4

thanks guys!