Open file earlier, drop privileges where appropriate.