Redirecting Arduino Serial Output to a File
Well, I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())


The idea, here, is to print on stdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 &gt; output.log


or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())


which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log


Hope this helps!