<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_requirements(reqs_linenum, req_file):
 """Writes a list of req objects out to a given file."""

    with open(req_file, 'r') as input:
        lines = input.readlines()

    for req in reqs_linenum:
        line_num = int(req[1])

        if hasattr(req[0], 'link'):
            lines[line_num - 1] = '{}\n'.format(req[0].link)
        else:
            lines[line_num - 1] = '{}\n'.format(req[0])

    with open(req_file, 'w') as output:
        output.writelines(lines)