add special handling for empty files; implements #645