Fixed the writing of positions, thanks to @Thinkofdeath for pointing it out.