Fixed file writing
Merge branches 'master' and 'realtime'