Factor out file initialization into a separate function for clarity