Fix bug with writing files size 0 byte