Error checking added, need to verify file path output is correct