Input loop is part of Short Circuit's Console Program Basics selection.
Task

Read from a text stream either word-by-word or line-by-line until the stream runs out of data.

The stream will have an unknown amount of data on it.




% Implemented by Arjun Sunel
-module(read_files).
-export([main/0]).
 
main() ->
	Read = fun (Filename) -> {ok, Data} = file:read_file(Filename), Data end,
	Lines = string:tokens(binary_to_list(Read("read_files.erl")), "\n"),
	lists:foreach(fun (Y) -> io:format("~s~n", [Y]) end, lists:zipwith(fun(X,_)->X end, Lines, lists:seq(1, length(Lines)))).
 