Made it work for arbitrarily large files