Using ftruncate
Fixed returned indices from delete