# Printing an array into a text file

**URL:** <https://discourse.julialang.org/t/printing-an-array-into-a-text-file/14101>\
**Category:** New to Julia\
**Tags:** array\
**Created:** [August 26, 2018, 11:22pm UTC](https://discourse.julialang.org/t/printing-an-array-into-a-text-file/14101 "2018-08-26T23:22:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [August 26, 2018, 11:40pm UTC](https://discourse.julialang.org/t/printing-an-array-into-a-text-file/14101/2 "2018-08-26T23:40:01Z")

</div>

Welcome!

First, check out [how to quote your code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) to maintain readability.

The issue is that your iterator `for i in notes` means that each `i` is the element of `notes`. So what you want is

```julia
for i in notes # or for note in notes
println(f, i)
end

```

Or if you want to iterate through the indices of `notes`, you can use the function `eachindex`

```julia
for i in eachindex(notes)
println(f, notes[i])
end

```

---

_[View the full topic](https://discourse.julialang.org/t/printing-an-array-into-a-text-file/14101)._
