Refactor seed_file function