sura2k
sura2k

Reputation: 7517

How to write a line by line to a file in Erlang

As in the title or how to write to a new line in Erlang?

Thank You!

Upvotes: 1

Views: 1535

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170745

Use the io:fwrite functions. See this article and this tutorial for examples.

Here is a short snippet to showcase,

39> {ok, FD} = file:open("test.txt",[read, write]).
{ok,<0.130.0>}
40> io:fwrite(FD, "First line  ~n", []).
ok
41> io:fwrite(FD, "Second line  ~n", []).
ok

Upvotes: 6

Related Questions