Decided to read the source code and found this:
Warning: Every time this function is invoked, a file descriptor is opened
and a new process is spawned to write to the file. For this reason, if you are
doing multiple writes in a loop, opening the file via File.open/2 and using
the functions in IO to write to the file will yield much better performance
than calling this function multiple times.
That’s on File.write.
Going to refactor with file stream in state and writes via IO module and see if that improves the situation.






















