#!/usr/bin/env python3

import sys
import os

import unidecode

script = sys.argv[0]
args = sys.argv[1:]

def usage():
    return "%s FILE\n" % os.path.basename(script)

if len(args) < 1:
    sys.stderr.write(usage())
    sys.exit(1)

def unaccent(file):
    for line in file:
        print(unidecode.unidecode(line),
            end='', flush=True)

    file.close()

if len(args) == 1:
    arg = args[0]

    if arg == "-":
        unaccent(sys.stdin) # '-' reads from standard input
        sys.exit(0)

for arg in args:
    file_to_unaccent = open(arg)
    unaccent(file_to_unaccent)
