Fixed more init error, created the file writing code