Fixing reading and writing larger files