with open('input.txt', 'r') as _in:
    nums = map(bin, map(int, _in.read().split()))
with open('output.txt', 'w') as out:
    out.writelines(map(lambda b: b + '\n', map(lambda n: n.replace('0b', ''
        ), nums)))
Turn a file content into a binary array