title: Erlang compare two binary file line by line
body: <p>I tried to compare difference from two binary file, but get confused to compare line by line when reading the file. Like read the first line in the both files, then compare, then read second line of both files to compare</p>
  
  <pre><code>read(B1,B2) -&gt;
      {ok, Binary} = file:read_file(B1),
      X=[binary_to_list(Bin)||Bin&lt;-binary:split(Binary, [&lt;&lt;"\n"&gt;&gt;], [global])],
      {ok, Data} = file:read_file(B2),
      Y=[binary_to_list(Bin)||Bin&lt;-binary:split(Data, [&lt;&lt;"\n"&gt;&gt;], [global])],
      compare(X,Y).
  
  compare(X,Y)-&gt;
      C3=lists:subtract(F1, F2),
      io:format("~p~p",[C3,length(C3)]).
  </code></pre>