Fix error output and simplify file-path variable use