Added explicit directory creation which is required for creating files in Windows.