File creation with system permissions; remove unnecessary code duplication