only sudo the file writing part