<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_bval_file(bvals, bval_file):
 """ Write an array of bvals to a bval file :param bvals: array with the values :param bval_file: filepath to write to """

    if bval_file is None:
        return
    logger.info('Saving BVAL file: %s' % bval_file)
    with open(bval_file, 'w') as text_file:
        # join the bvals using a space and write to the file
        text_file.write('%s\n' % ' '.join(map(str, bvals)))