Added check to make sure m_location isn't null before attempting to write position to file