Added check before writing to file
Switched to Qt5