Intermediate directories are created if necessary.
Added missing newline to error message.