fixed very hard bug:  added flush() to writePOSCAR subroutines