Give the read and write loop their own func.
Give the main chunk moving logic its own func.