#!/usr/bin/env python
from sys import stdin


def main():
    for filepath in stdin:
        filepath = filepath.strip()
        with open(filepath, "r", encoding="utf-8") as file:
            lines = file.readlines()
        lines = list(filter(identity, map(strip, lines)))
        with open(filepath, "w", encoding="utf-8") as file:
            for line in lines:
                print(line, file=file)
        print(filepath)


def identity(value):
    return value


def strip(value):
    return value.strip()


if __name__ == "__main__":
    main()
