#!/usr/bin/env python
# -*- coding=UTF-8 -*-
"""
SUM OF DIGITS.

CHALLENGE DESCRIPTION:
Given a positive integer, find the sum of its constituent digits.

INPUT SAMPLE:
The first argument will be a path to a filename containing positive integers,
one per line.

OUTPUT SAMPLE:
Print to stdout, the sum of the numbers that make up the integer, one per line.
"""
# Future
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)

# Standart Library
import sys


def sum_of_digits(line):
    """Return a sum of digits in a line."""
    total = 0
    for digit in line.rstrip('\n'):
        total += int(digit)
    return total


def file_lines(file_location):
    """Output file line-by-line."""
    with open(file_location, 'r') as a_file:
        for line in a_file:
            yield line


def main():
    """Program entry point."""
    file_location = sys.argv[1]
    for line in file_lines(file_location):
        print(sum_of_digits(line))


if __name__ == '__main__':
    main()
