Refactoring createfile