More robust file opening.

Uses boost to make the directory, if directory doesn't exist.