Fixed issue of remaining file content, when overwriting files with smaller files