<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def CreateMuskingumXFileFromDranageLine(in_drainage_line, x_id, out_x_file, file_geodatabase=None):
 """ Create muskingum X file from drainage line. Parameters in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. x_id: str The name of the muksingum X field (i.e. 'Musk_x'). out_x_file: str The path to the output x file. file_geodatabase: str, optional Path to the file geodatabase. If you use this option, in_drainage_line is the name of the stream network feature class (WARNING: Not always stable with GDAL). Example:: from RAPIDpy.gis.muskingum import CreateMuskingumXFileFromDranageLine CreateMuskingumXFileFromDranageLine( in_drainage_line='/path/to/drainageline.shp', x_id='Musk_x', out_x_file='/path/to/x.csv') """

    ogr_drainage_line_shapefile_lyr, ogr_drainage_line_shapefile = \
        open_shapefile(in_drainage_line, file_geodatabase)

    with open_csv(out_x_file, 'w') as kfile:
        x_writer = csv_writer(kfile)
        for drainage_line_feature in ogr_drainage_line_shapefile_lyr:
            x_writer.writerow([drainage_line_feature.GetField(x_id)])

    del ogr_drainage_line_shapefile