Extract file handling to a separated class.
Adjust indent.