# Invalid\_argument("UTF8.next") when iterating a split string

**URL:** <https://community.haxe.org/t/invalid-argument-utf8-next-when-iterating-a-split-string/3480>\
**Category:** Haxe\
**Tags:** haxe-cpp\
**Created:** [February 27, 2022, 1:47pm UTC](https://community.haxe.org/t/invalid-argument-utf8-next-when-iterating-a-split-string/3480 "2022-02-27T13:47:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiffolisk](https://community.haxe.org/user_avatar/community.haxe.org/kiffolisk/32/1847_2.png) [@Kiffolisk](https://community.haxe.org/u/Kiffolisk)\
**Post date:** [February 27, 2022, 1:47pm UTC](https://community.haxe.org/t/invalid-argument-utf8-next-when-iterating-a-split-string/3480/1 "2022-02-27T13:47:30Z")

</div>

I’m trying to make a file reader and it has to read every line. I had this issue and found out it happens in a for loop.

```haxe
var lines:String = File.getContent(fullPath);
for (line in lines.toString().split('\n') /* here is the error */)
{
// more code
}

```

The files exist, the directory exists, I’ve implemented many checks and the only thing that works is removing the .split("\n") which iterates through ints (I’m guessing they’re byte values for each character).
