def METHOD_NAME(self, overwrite=False):
    """Write script to file.
    The working directory is created if needed.
    Args:
        overwrite (bool): Whether to overwrite script file if it
            already exists (default: false).
    """
    # Create directories if needed
    os.makedirs(self.work_dir, exist_ok=True)
    os.makedirs(os.path.dirname(self.script_file), exist_ok=True)
    # Check if script file already exists
    if not overwrite and os.path.isfile(self.script_file):
        raise RuntimeError('Attempted to write batch script to {}, '
                           'but it already exists'
                           .format(self.script_file))
    # Write script to file
    with open(self.script_file, 'w') as f:
        for line in self.header:
            f.METHOD_NAME('{}\n'.format(line))
        f.METHOD_NAME('\n')
        for line in self.body:
            f.METHOD_NAME('{}\n'.format(line))
    # Make script file executable
    os.chmod(self.script_file, 0o755)