# Very weird error reading multi-line .txt file

**URL:** <https://forum.kirupa.com/t/very-weird-error-reading-multi-line-txt-file/308607>\
**Category:** flash\
**Created:** [April 26, 2010, 10:31pm UTC](https://forum.kirupa.com/t/very-weird-error-reading-multi-line-txt-file/308607 "2010-04-26T22:31:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maqrkk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Maqrkk](https://forum.kirupa.com/u/Maqrkk)\
**Post date:** [April 26, 2010, 10:31pm UTC](https://forum.kirupa.com/t/very-weird-error-reading-multi-line-txt-file/308607/1 "2010-04-26T22:31:15Z")

</div>

Hello,

sorry to be asking so many questions on the same day, but they are all different and have all got me stunned. This time I’m reading a 2d array from a .txt file, this is what I do:

```auto
[Embed(source = '../lib/lvl1front.txt', mimeType = "application/octet-stream")]
private var frontTxt:Class;

```

Then a bit further:

```auto
var fgString:String = new frontTxt();
foreGround = stringToArray(fgString);

```

The stringToArray function is where things go horribly bad:

```auto
private function stringToArray(input:String):Array
{
	var output:Array = new Array();

	var rows:Array = input.split("
");
	for (var i:uint = 0; i < rows.length; i++)
	{
		var row:String = rows* as String;
		var column:Array = row.split(",");
		var newArray:Array = new Array();

		for (var j:uint = 0; j < column.length; j++)
		{
			var data:uint = column[j] as uint;
			newArray.push(column[j]);
		}

		output* = newArray;
	}

	trace(output);
	return output;
}

```

I get no errors at all so far. But this is what the trace shows:

```auto
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,0,0,0,0,0,1,4,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,0,0,1
,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1
,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,1,0,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1

```

etc.

Notice the starting comma on every line except the first? I think it’s the newline character somehow interfering, but I’ve tried everything I can think of, and nothing has helped. How can I fix this?

- Maqrkk
