Corrected the behaviour for empty files