<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stdin(self, line, prompt=True, timeout=3):
 """ Send line to stdin, optionally expect a prompt. :param line: line to be send to stdin :type line: str :param prompt: boolean indicating whether a prompt is expected, if True absorbs \ all of stdout before inserting line into stdin and raises \ :class:`check50.Failure` if stdout is empty :type prompt: bool :param timeout: maximum number of seconds to wait for prompt :type timeout: int / float :raises check50.Failure: if ``prompt`` is set to True and no prompt is given """

        if line == EOF:
            log("sending EOF...")
        else:
            log(_("sending input {}...").format(line))

        if prompt:
            try:
                self.process.expect(".+", timeout=timeout)
            except (TIMEOUT, EOF):
                raise Failure(_("expected prompt for input, found none"))
            except UnicodeDecodeError:
                raise Failure(_("output not valid ASCII text"))
        try:
            if line == EOF:
                self.process.sendeof()
            else:
                self.process.sendline(line)
        except OSError:
            pass
        return self