<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encrypt_file(in_path_or_file, out_path_or_file, pk, pk_format=SER_COMPACT, mac_bytes=10, chunk_size=4096, curve=None):
 """ Encrypts `in_file' to `out_file' for pubkey `pk' """

    close_in, close_out = False, False
    in_file, out_file = in_path_or_file, out_path_or_file
    try:
        if stringlike(in_path_or_file):
            in_file = open(in_path_or_file, 'rb')
            close_in = True
        if stringlike(out_path_or_file):
            out_file = open(out_path_or_file, 'wb')
            close_out = True
        _encrypt_file(in_file, out_file, pk, pk_format, mac_bytes, chunk_size,
                      curve)
    finally:
        if close_out:
            out_file.close()
        if close_in:
            in_file.close()