Fixed the endif problem with changing file modes.