Improve CommitFile to avoid the unnecessary copying of char arrays