fixed a bug in writePath()