added deallocation of blocks if write was smaller than current file size