Fixed write to directory issue. Silly mistake.