Figured out NULL errors.
Simplified the code for redirecting output to file path. Redirecting and
redirecting with commands works.