def _UpdateCommandLineFile(self):
    """Writes out the command line to the file, or removes it if empty."""
    logging.info('Current flags: %s', self._current_flags)
    # Root is not required to write to /data/local/tmp/.
    use_root = '/data/local/tmp/' not in self._cmdline_file
    if self._current_flags:
      # The first command line argument doesn't matter as we are not actually
      # launching the chrome executable using this command line.
      cmd_line = ' '.join(['_'] + self._current_flags)
      self._device.WriteFile(
          self._cmdline_file, cmd_line, as_root=use_root)
      file_contents = self._device.ReadFile(
          self._cmdline_file, as_root=use_root).rstrip()
      assert file_contents == cmd_line, (
          'Failed to set the command line file at %s' % self._cmdline_file)
    else:
      self._device.RunShellCommand('rm ' + self._cmdline_file,
                                   as_root=use_root)
      assert not self._device.FileExists(self._cmdline_file), (
          'Failed to remove the command line file at %s' % self._cmdline_file)