# Adding array of strings to text file line by line

**URL:** <https://forums.unrealengine.com/t/adding-array-of-strings-to-text-file-line-by-line/287744>\
**Category:** Community & Industry Discussion\
**Tags:** unreal-engine, saving, question\
**Created:** [July 9, 2014, 2:12pm UTC](https://forums.unrealengine.com/t/adding-array-of-strings-to-text-file-line-by-line/287744 "2014-07-09T14:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pots3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pots3](https://forums.unrealengine.com/u/Pots3)\
**Post date:** [July 9, 2014, 2:12pm UTC](https://forums.unrealengine.com/t/adding-array-of-strings-to-text-file-line-by-line/287744/1 "2014-07-09T14:12:19Z")

</div>

I was wondering if this was possible as I currently read in strings line by line from a text file using

```
LoadANSITextFileToStrings(*projectDir, NULL, names);

```

which reads in an array of strings line by line and then adds them to an existing array in my project.

So is it possible to write to a text file in a similar way that unreal provides?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [July 9, 2014, 10:48pm UTC](https://forums.unrealengine.com/t/adding-array-of-strings-to-text-file-line-by-line/287744/2 "2014-07-09T22:48:47Z")

</div>

#Adding String Data Line by Line

You have your core data as

```
FString StringData = "";

```

Then you add lines like this

```
if(StringData != "")
{
   StringData += "\n"; //newline
}

//Add new text
StringData += NextLineOfText; //can be FString or TCHAR*

```

then you write out the String to file using Epic’s function:

#SaveStringToFile

```
FFileHelper::SaveStringToFile(SaveText, * SaveDirectory);

```

#String Array

if you have an array of string you can use the ranged for each with your array and my code above

```
TArray<FString> YourData;

for(const FString& EachString : YourData)
{
  //use code above to add EachString to the total StringData.
}

```

#Wiki With More Info

**Saving To Text Files**

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Rama

---

<div class="post-metadata">

**Author:** ![Kelt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kelt](https://forums.unrealengine.com/u/Kelt)\
**Post date:** [March 4, 2016, 3:59am UTC](https://forums.unrealengine.com/t/adding-array-of-strings-to-text-file-line-by-line/287744/3 "2016-03-04T03:59:23Z")

</div>

I have one question, what do you mean under “EachString”?
