Dynamic allocation of buffers

This code handles the partial reading of files and handling memory
dynamically