Save the file by hitting Ctrl+O, then quit nano with Ctrl+X. Close the terminal window. (You can type the command exit to do this). Then, open a new terminal window and type any command with sudo, ...