Adaptive arithmetic coding confusion
First, consider &quot;going through an entire file&quot;. There are a few assumptions worth thinking about here.
Files can be very big, and traversing them twice can be expensive. This is one reason why most real-world compression standards are based around blocks or windows.
There are situations where you don't have &quot;the entire file&quot; to begin with, such as a communication channel. TLS (prior to 1.3, at least) supports compression, for example.
Files are not always homogeneous. Archives (e.g. tar) are a case in point. A statistical model that is appropriate for one part of a file may not be appropriate for another part. Adaptive coding adapts to this, too.
As to your final question, if both the encoder and decoder knew the true probabilities of the symbols in the file we are compressing, then that wouldn't need to be transmitted. And, indeed, we sometimes do this in the real world. The JPEG standard, for example, specifies default coding tables for those times when they are appropriate, and lets an encoder supply their own when they are not.
Transmitting a static coding table efficiently (i.e. compressing it) is a nontrivial problem, especially for a large code alphabet. For a well-designed scheme, the cost of transmitting the table should be equal to the &quot;learning cost&quot; of using an adaptive code.