Enhanced the file handler

Implements #3 and #4