read whole files and allocate space as needed