This obviously causes OOM problems with very large files. Maybe we can use mmap instead. But I'm not sure if we would sacrifice OS independence.